Coding Villa

CREATE MODIFY DELETE TASKS COMMAND LINE

Author : Zaryab Liaqat

Share with Friends
Views : 462
Ratings : 0
Bookmarks : 0
Farourities : 0

Description


There is Schtask command, by which you can use the command line that allows you to control all aspects of your scheduled task. By this command you can automatically manipulates in batch scripts as well as custom programs to communicate with the task scheduler.


Advertisements



 

In short the command line tool is ideal for following situation:


·    Manipulates tasks in batch scripts.


·     Control and create  tasks on networks machine without log in to them.


·    Mass create/sync task across multiple machine.


·    Used in custom applications  to communicate with the task scheduler instead of having to make API calls


Perhaps you can imagine that the SchTasks command has more option than we have discussed above so we are going to show some examples of common task configurations and how the respective task looks like in the task scheduler


EXAMPLES


CREAT ‘ MY TASK ’ TO RUN C.RunMe.bat at 9 am everyday:


<SchTasks /Create /SC DAILY /TN “My Task” /TR “C:RunMe.bat” /ST 09:00>

 

 

Modify ‘My Task’ to run at 2 pm:

<SchTasks /Change /TN “My Task” /ST 14:00>

 

 

 

Create ‘My Task’ to Run C: RunMe. On the first of every month:

 

<SchTasks /Create /SC MONTHLY /D 1 /TN “My Task” /TR “C:RunMe.bat” /ST 14:00>

 

 

Create ‘My Task’ to run C: RunMe.bat every weekday at 2pm:


<SchTasks /Create /SC WEEKLY /D MON,TUE,WED,THU,FRI /TN “My Task” /TR “C:RunMe.bat” /ST 14:00>

 

 

Delete the task named My Task

 

<SchTasks /Delete /TN “My Task”>

 

 

Note: warning will raise which will need to be confirmed.

 

BULK CREATION:

 

You can include multiple instructions in a batch file to enable bulk creation or deletion like other command line tool.

 

As an example, this script:

 

SchTasks /Create /SC DAILY /TN “Backup Data” /TR “C:Backup.bat” /ST 07:00
SchTasks /Create /SC WEEKLY /D MON /TN “Generate TPS Reports” /TR “C:GenerateTPS.bat” /ST 09:00
SchTasks /Create /SC MONTHLY /D 1 /TN “Sync Database” /TR “C:SyncDB.bat” /ST 05:00
 

Produces these tasks.

 

 

This is quick way to do new tasks and change existing schedule to many machine at once.


To make sure that the tasks are updated you will need to include the appropriate Schtask command in a domain login scripts by which user machines will update when they are log in. 

 



Article Tags
Share with Friends

Comments




Leave a Reply

Name (required)  
Mail (will not be published) (required)   
 
Enter This Code
Captcha
 

Advertisements

Article Categories

.NET


Databases


Mobile Development


Operating Systems


Web Development


Coding Villa on Facebook