≡ Menu

Schedule tasks from command line

Schedule tasks‘ is a GUI application using which we can schedule tasks, There is an equivalent utility which provides the same functionality but with the advantage that it can be used from windows command line. This command is Schtasks. This is an in-built windows command supported by XP, Vista and Windows 7. Let’s see the syntax of this command with the help of few examples.

How to schedule a task ?

If you are logged into the same computer where you want to run the scheduled task, then you can use the below command to create the task.

Schtasks create /RU username /RP password /SC schedule_frequency /MO Schedule_modifier /D days /M months /TN taskname /TR Task_command /ST start_time /SD start_day /ED end_date

Now let’s see few examples.

Example 1: Schedule disk defragmentation on every Saturday at 10AM. User credentials are administrator/password.

Schtasks /create /RU administrator /RP adminpassword /SC weekly /D SAT /TN defrag /TR c:\windows\system32\defrag.exe /ST 10:00:00

If the specified username and password are correct, then you would get the below message when you run the above command.

SUCCESS: The scheduled task "defrag" has successfully been created.

If the credentials are not correct, you may get a warning like below.

WARNING: The Scheduled task "defrag5" has been created, but may not run because the account information could not be set.

If there exists a scheduled task with the same name then the error would be:

specified task name already exists in the system.

If you need to use a domain user account to run the task you can specify domainname\username with /RU option.

How to get the list of scheduled tasks?

Just run Schtasks command and you can see the list of scheduled commands.


TaskName                             Next Run Time            Status
==================================== ======================== ===============
defrag                               10:00:00, 3/12/2011
GoogleUpdateTaskUserS-1-5-21-3567637 11:14:00, 3/6/2011
GoogleUpdateTaskUserS-1-5-21-3567637 13:14:00, 3/5/2011

If you want complete details about each of the tasks you can run the command ‘Schtasks /query /v

Delete  a scheduled task

We can delete a schedule task using ‘schtasks /delete /TN task_name‘ command.  For example, to delete the task we created in the example 1 we can run the below command.

Schtasks /delete /TN defrag

Delete all the scheduled tasks

You can run the below command to delete all the scheduled tasks.

schtasks /delete /TN *

Disable a scheduled task

There does not seem to be a way to disable a scheduled task from command line. We can delete the tasks as mentioned above.

Modify  a scheduled task:

We can change a scheduled task using ‘schtasks /change’ command. Run ‘schtasks /change /?’ for the syntax.


7 comments… add one
  • Alex

    how to delete from the folder?

  • vlci

    schtasks /delete /TN “Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser” /F

  • Yavor

    It is possibile to disable sheduled task. Here is an example:
    schtasks /Change /TN “Microsoft\Windows\MUI\LPRemove” /Disable

  • chanchinliana

    Thank you all.

  • Neo

    How do you do it if the task is meant to be run on a DIFFERENT computer (like with the “connect to another computer”)? Thank you! On cmd please.

  • Nikolaus MEURY


    I’m regarding to run a batch file by a schedule task.

    This script is running chrome with a specific url.

    The problem is that I must choose some credential in my command line like this :
    schtasks /create /sc once /tn Video_XP /tr “\\myserver\myscript.bat” /u contoso\admin /p mypassword /st 12:25:00

    The problem is that the task is running with an other account than the login one.

    If I replace /u by %username% i’m not able to specify the passord and the task will stuck in background requesting password.

    Any ideas ?

  • Rohan

    Please tell how can I know whether a task is Enabled/Disabled using CMD queries
    Please provide a Example supporting your answer.

Leave a Comment