반응형

 

기본 형식

schtasks /create ---

 

/create 뒤에 인수들을 추가하면 된다.

가장 많이 쓸만한 인수들을 정리해봤다.

 

/sc 스케줄타입 /tn "작업 이름" /tr "실행할 명령어, 프로그램 경로" /st "시작할 시간" /et "끝낼 시간"

 

여기서 쌍따옴표 붙인건 쌍따옴표를 붙여야 작동하는 인수들이다.

 

시간은 반드시 24시간형식으로 써야한다.

 

스케줄 타입 명령어로는

MINUTE - 매 분마다

HOURLY - 매 시간마다

DAILY - 매일마다

WEEKLY - 매주마다

MONTHLY - 매달마다

ONCE - 1회만

ONLOGON - 로그온시 매번

ONIDLE - 아이들 상태로 진입시 매번

 

이렇게 있다.

 

예시로 자동 종료 작업을 추가하도록 명령어를 써보겠다.

자동 종료 명령어 관련해서는 아래 글을 참고하길 바란다.

 

https://blog.naver.com/joshuasuah/222155389020

 

윈도우 자동 종료/재부팅 설정법

가끔 컴퓨터를 정해진 시간에 끄거나 재부팅 하고싶을때가 있습니다.컴퓨터 대수가 적으면 직접 끄면 되지...

blog.naver.com

 

 

schtasks /create /sc daily /tn "auto_off" /tr "shutdown -s -t 5 -f" /st "23:00"

 

이렇게 하면 매일 23시(오후 11시)에 auto_off라는 이름의 작업이 실행되어 컴퓨터가 자동 종료되게 된다.

 

이런식으로 인수들을 활용해 작업을 등록하면 된다.

 

 

 

참고 : 마이크로소프트 독스

이미지 썸네일 삭제

schtasks create

Reference article for the schtasks create command, which

docs.microsoft.com

형식

schtasks /create /sc <scheduletype> /tn <taskname> /tr <taskrun> [/s <computer> [/u [<domain>\]<user> [/p <password>]]] [/ru {[<domain>\]<user> | system}] [/rp <password>] [/mo <modifier>] [/d <day>[,<day>...] | *] [/m <month>[,<month>...]] [/i <idletime>] [/st <starttime>] [/ri <interval>] [{/et <endtime> | /du <duration>} [/k]] [/sd <startdate>] [/ed <enddate>] [/it] [/z] [/f]

파라미터

/sc <scheduletype> Specifies the schedule type. The valid values include: MINUTE - Specifies the number of minutes before the task should run. HOURLY - Specifies the number of hours before the task should run. DAILY - Specifies the number of days before the task should run. WEEKLY Specifies the number of weeks before the task should run. MONTHLY - Specifies the number of months before the task should run. ONCE - Specifies that that task runs once at a specified date and time. ONSTART - Specifies that the task runs every time the system starts. You can specify a start date, or run the task the next time the system starts. ONLOGON - Specifies that the task runs whenever a user (any user) logs on. You can specify a date, or run the task the next time the user logs on. ONIDLE - Specifies that the task runs whenever the system is idle for a specified period of time. You can specify a date, or run the task the next time the system is idle.

/tn <taskname> Specifies a name for the task. Each task on the system must have a unique name and must conform to the rules for file names, not exceeding 238 characters. Use quotation marks to enclose names that include spaces.

/tr <Taskrun> Specifies the program or command that the task runs. Type the fully qualified path and file name of an executable file, script file, or batch file. The path name must not exceed 262 characters. If you don't add the path, schtasks assumes that the file is in the <systemroot>\System32 directory.

 

/s <computer> Specifies the name or IP address of a remote computer (with or without backslashes). The default is the local computer.

/u [<domain>] Runs this command with the permissions of the specified user account. The default is the permissions of the current user of the local computer. The /u and /p parameters are valid only when you use /s. The permissions of the specified account are used to schedule the task and to run the task. To run the task with the permissions of a different user, use the /ru parameter. The user account must be a member of the Administrators group on the remote computer. Also, the local computer must be in the same domain as the remote computer, or must be in a domain that is trusted by the remote computer domain.



/p <password> Specifies the password of the user account specified in the /u parameter. If you use the /u parameter without the /p parameter or the password argument, schtasks will prompt you for a password. The /u and /p parameters are valid only when you use /s.



/ru {[<domain>\]<user> | system} Runs the task with permissions of the specified user account. By default, the task runs with the permissions of the current user of the local computer, or with the permission of the user specified by the /u parameter, if one is included. The /ru parameter is valid when scheduling tasks on local or remote computers. The valid options include: Domain - Specifies an alternate user account. System - Specifies the local System account, a highly privileged account used by the operating system and system services.



/rp <password> Specifies a the password for the existing user account, or the user account specified by the /ru parameter. If you don't use this parameter when specifying a user account, SchTasks.exe will prompt you for the password next time you sign in. Don't use the /rp parameter for tasks that run with System account credentials (/ru System). The System account doesn't have a password and SchTasks.exe doesn't prompt for one.



/mo <modifiers> Specifies how often the task runs within its schedule type. The valid options include: MINUTE - Specifies that the task runs every minutes. You can use any value between 1 - 1439 minutes. By default, this is 1 minute. HOURLY - Specifies that the task runs every hours. You can use any value between 1 - 23 hours. By default, this is 1 hour. DAILY - Specifies that the task runs every days. You can use any value between 1 - 365 days. By default, this is 1 day. WEEKLY - Specifies that the task runs every weeks. You can use any value between 1 - 52 weeks. By default, this is 1 week. MONTHLY - Specifies that the task runs every months. You can use any of the following values: A number between 1 - 12 months LASTDAY - To run the task on the last day of the month FIRST, SECOND, THIRD, or FOURTH along with the /d <day> parameter - Specifies the particular week and day to run the task. For example, on the third Wednesday of the month. ONCE - Specifies that the task runs once. ONSTART - Specifies that the task runs at startup. ONLOGON - Specifies that the task runs when the user specified by the /u parameter logs on. ONIDLE - Specifies that the task runs after the system is idle for the number of minutes specified by the /i parameter



/d DAY[,DAY...] Specifies how often the task runs within its schedule type. The valid options include: WEEKLY - Specifies that the task runs weekly by providing a value between 1-52 weeks. Optionally, you can also add a specific day of the week by adding a value of MON - SUN or a range of [MON - SUN...]). MONTHLY - Specifies that the task runs weekly each month by providing a value of FIRST, SECOND, THIRD, FOURTH, LAST. Optionally, you can also add a specific day of the week by adding a value of MON - SUN or by providing a number between 1 - 12 months. If you use this option, you can also add a specific day of the month, by providing a number between 1-31. NOTE: The date value of 1 - 31 is valid only without the /mo parameter, or if the /mo parameter is monthly (1 - 12). The default is day 1 (the first day of the month).



/m MONTH[,MONTH...] Specifies a month or months of the year during which the scheduled task should run. The valid options include JAN - DEC and * (every month). The /m parameter is valid only with a MONTHLY schedule. It's required when the LASTDAY modifier is used. Otherwise, it's optional and the default value is * (every month).



/i Specifies how many minutes the computer is idle before the task starts. A valid value is a whole number from 1 to 999. This parameter is valid only with an ONIDLE schedule, and then it's required.



/st <Starttime> Specifies the start time for the task, using the 24-hour time format, HH:mm. The default value is the current time on the local computer. The /st parameter is valid with MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, and ONCE schedules. It's required for a ONCE schedule.



/ri <interval> Specifies the repetition interval for the scheduled task, in minutes. This isn't applicable for schedule types: MINUTE, HOURLY, ONSTART, ONLOGON, and ONIDLE. Valid range is 1 - 599940 (599940 minutes = 9999 hours). If either the /et or /du parameters are specified, the default is 10 minutes.



/et <Endtime> Specifies the time of day that a minute or hourly task schedule ends in <HH:MM> 24-hour format. After the specified end time, schtasks does not start the task again until the start time recurs. By default, task schedules have no end time. This parameter is optional and valid only with a MINUTE or HOURLY schedule.



/du <duration> Specifies a maximum length of time for a minute or hourly schedule in HHHH:MM 24-hour format. After the specified time elapses, schtasks does not start the task again until the start time recurs. By default, task schedules have no maximum duration. This parameter is optional and valid only with a MINUTE or HOURLY schedule.



/k Stops the program that the task runs at the time specified by /et or /du. Without /k, schtasks doesn't start the program again after it reaches the time specified by /et or /du nor does it stop the program if it's still running. This parameter is optional and valid only with a MINUTE or HOURLY schedule.



/sd Specifies the date on which the task schedule starts. The default value is the current date on the local computer. The format for Startdate varies with the locale selected for the local computer in Regional and Language Options. Only one format is valid for each locale. The valid date formats include (be sure to choose the format most similar to the format selected for Short date in Regional and Language Options on the local computer): <MM>// - Specifies to use month-first formats, such as English (United States) and Spanish (Panama). <DD>// - Specifies to use day-first formats, such as Bulgarian and Dutch (Netherlands). <YYYY>// - Specifies to use for year-first formats, such as Swedish and French (Canada).



/ed <Enddate> Specifies the date on which the schedule ends. This parameter is optional. It isn't valid in a ONCE, ONSTART, ONLOGON, or ONIDLE schedule. By default, schedules have no ending date. The default value is the current date on the local computer. The format for Enddate varies with the locale selected for the local computer in Regional and Language Options. Only one format is valid for each locale. The valid date formats include (be sure to choose the format most similar to the format selected for Short date in Regional and Language Options on the local computer): <MM>// - Specifies to use month-first formats, such as English (United States) and Spanish (Panama). <DD>// - Specifies to use day-first formats, such as Bulgarian and Dutch (Netherlands). <YYYY>// - Specifies to use for year-first formats, such as Swedish and French (Canada).



/it Specifies to run the scheduled task only when the run as user (the user account under which the task runs) is logged on to the computer. This parameter has no effect on tasks that run with system permissions or tasks that already have the interactive-only property set. You can't use a change command to remove the interactive-only property from a task. By default, run as user is the current user of the local computer when the task is scheduled or the account specified by the /u parameter, if one is used. However, if the command includes the /ru parameter, then the run as user is the account specified by the /ru parameter.



/z Specifies to delete the task upon the completion of its schedule.



/f Specifies to create the task and suppress warnings if the specified task already exists.



/? Displays help at the command prompt.

 

 

반응형

'윈도우' 카테고리의 다른 글

윈도우 시계에 초 표시하는법  (0) 2021.04.12
윈도우 자동 종료/재부팅 설정법  (0) 2021.03.19
윈도우 10 초기 설정 및 최적화  (0) 2021.03.18

+ Recent posts