text
stringlengths
0
4.23k
When scheduling tasks on a remote computer, all parameters refer to the remote computer. Therefore, the file specified by the /tr parameter refers to the copy of MyApp.exe on the remote computer.
To schedule the MyApp program (as a user) to run on the SRV06 remote computer every three hours, type:
schtasks /create /s SRV06 /tn MyApp /tr c:\program files\corpapps\myapp.exe /sc hourly /mo 3 /u reskits\admin01 /p R43253@4$ /ru SRV06\user03 /rp MyFav!!Pswd
Because Administrator permissions are required to schedule a task, the command uses the /u and /p parameters to provide the credentials of the user's Administrator account (Admin01 in the Reskits domain). By default, these permissions are also used to run the task. However, because the task does not need Administrator permissions to run, the command includes the /u and /rp parameters to override the default and run the task with permission of the user's non-Administrator account on the remote computer.
To schedule the MyApp program (as a user) to run on the SRV02 remote computer on the last day of every month.
schtasks /create /s SRV02 /tn MyApp /tr c:\program files\corpapps\myapp.exe /sc monthly /mo LASTDAY /m * /u reskits\admin01
Because the local current user (user03) isn't an Administrator of the remote computer, the command uses the /u parameter to provide the credentials of the user's Administrator account (Admin01 in the Reskits domain). The Administrator account permissions will be used to schedule the task and to run the task.
Because the command did not include the /p (password) parameter, schtasks prompts for the password. Then it displays a success message and, in this case, a warning:
Type the password for reskits\admin01:********
SUCCESS: The scheduled task MyApp has successfully been created.
WARNING: The scheduled task MyApp has been created, but may not run because the account information could not be set.
This warning indicates that the remote domain could not authenticate the account specified by the /u parameter. In this case, the remote domain could not authenticate the user account because the local computer isn't a member of a domain that the remote computer domain trusts. When this occurs, the task job appears in the list of scheduled tasks, but the task is actually empty and it won't run.
The following display from a verbose query exposes the problem with the task. In the display, note that the value of Next Run Time is Never and that the value of Run As User is Could not be retrieved from the task scheduler database.
Had this computer been a member of the same domain or a trusted domain, the task would have been successfully scheduled and would have run as specified.
HostName: SRV44
TaskName: MyApp
Next Run Time: Never
Status:
Logon mode: Interactive/Background
Last Run Time: Never
Last Result: 0
Creator: user03
Schedule: At 3:52 PM on day 31 of every month, start
starting 12/14/2001
Task To Run: c:\program files\corpapps\myapp.exe
Start In: myapp.exe
Comment: N/A
Scheduled Task State: Disabled
Scheduled Type: Monthly
Start Time: 3:52:00 PM
Start Date: 12/14/2001
End Date: N/A
Days: 31
Months: JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NO
V,DEC
Run As User: Could not be retrieved from the task sched
uler database
Delete Task If Not Rescheduled: Enabled
Stop Task If Runs X Hours and X Mins: 72:0
Repeat: Every: Disabled
Repeat: Until: Time: Disabled
Repeat: Until: Duration: Disabled
Repeat: Stop If Still Running: Disabled
Idle Time: Disabled
Power Management: Disabled
Remarks
To run the /create command with the permissions of a different user, use the /u parameter. The /u parameter is valid only for scheduling tasks on remote computers.
To view more schtasks /create examples, type schtasks /create /? at a command prompt.
schtasks /create
schtasks /create /?
To schedule a task that runs with permissions of a different user, use the /ru parameter. The /ru parameter is valid for tasks on local and remote computers.
To use the /u parameter, the local computer must be in the same domain as the remote computer or it must be in a domain that the remote computer domain trusts. Otherwise, either the task isn't created, or the task job is empty and the task doesn't run.
Schtasks always prompts for a password unless you provide one, even when you schedule a task on the local computer using the current user account. This is normal behavior for schtasks.
Schtasks doesn't verify program file locations or user account passwords. If you don't enter the correct file location or the correct password for the user account, the task is created, but it won't run. Also, if the password for an account changes or expires, and you don't change the password saved in the task, then the task won't run.
The System account doesn't have interactive logon rights. Users don't see and can't interact with programs run with system permissions.
Each task runs only one program. However, you can create a batch file that starts multiple tasks, and then schedule a task that runs the batch file.
You can test a task as soon as you create it. Use the run operation to test the task and then check the SchedLgU.txt file (SystemRoot\SchedLgU.txt) for errors.
schtasks delete
Deletes a scheduled task from the schedule. This command doesn't delete the program that the task runs or interrupt a running program.
Syntax
schtasks /delete /tn {<taskname> | *} [/f] [/s <computer> [/u [<domain>\]<user> [/p <password>]]]
Parameters
Parameter
Description
/tn {<taskname> | *}
Identifies the task to be deleted. If you use the *, this command deletes all tasks scheduled for the computer, not just the tasks scheduled by the current user.
/f
Suppresses the confirmation message. The task is deleted without warning.
/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. By default, the command runs with the permissions of the current user of the local computer. The specified user account must be a member of the Administrators group on the remote computer. The /u and /p parameters are valid only when you use /s.
/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.
/?
Displays help at the command prompt.
{<taskname> | *}
*
<computer>