|
| |||||||||
| Tags: batch, scheduled |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| How to run a scheduled task via a batch job
How do I kick off a scheduled task in a batch script? We can bring up the scheduled tasks GUI interface, select a job and click run to run the job direct. But can I do it via a batch job? |
|
#2
| |||
| |||
| Re: How to run a scheduled task via a batch job akkha1234@gmail.com wrote: > How do I kick off a scheduled task in a batch script? We can bring up > the scheduled tasks GUI interface, select a job and click run to run > the job direct. But can I do it via a batch job? Assuming XP... C:\>schtasks /? SCHTASKS /parameter [arguments] Description: Enables an administrator to create, delete, query, change, run and end scheduled tasks on a local or remote system. Replaces AT.exe. Parameter List: /Create Creates a new scheduled task. /Delete Deletes the scheduled task(s). /Query Displays all scheduled tasks. /Change Changes the properties of scheduled task. /Run Runs the scheduled task immediately. /End Stops the currently running scheduled task. /? Displays this help/usage. Examples: SCHTASKS SCHTASKS /? SCHTASKS /Run /? SCHTASKS /End /? SCHTASKS /Create /? SCHTASKS /Delete /? SCHTASKS /Query /? SCHTASKS /Change /? C:\>schtasks /run /? SCHTASKS /Run [/S system [/U username [/P password]]] /TN taskname Description: Runs a scheduled task immediately. Parameter List: /S system Specifies the remote system to connect to. /U username Specifies the user context under which the command should execute. /P password Specifies the password for the given user context. /TN taskname Identifies the scheduled task to run. /? Displays this help/usage. Examples: SCHTASKS /Run /? SCHTASKS /Run /TN "Start Backup" SCHTASKS /Run /S system /U user /P password /TN "Backup and Restore" -- Michael Harris Microsoft.MVP.Scripting |
|
#3
| |||
| |||
| Re: How to run a scheduled task via a batch job
Hi, As a further note: A "scheduled task" is not the same thing as a "scheduled job". The "Scheduled Tasks" control panel GUI, and the "SCHTASKS" DOS command refer to the same set of constructs, i.e. "scheduled tasks". Whereas, the WMI interface "Win32_ScheduledJob" and the "AT" DOS command refer to a completely different set of constructs, i.e. "scheduled jobs". The AT command does support running a "job" remotely, and the SCHTASKS does support running a "task" remotely. N.B. also, the Win32_ScheduledJob object does not have a ".Run" method. So, to run either a scheduled "job" (created by AT or Win32_ScheduledJob) or a scheduled "task" (created via GUI or SCHTASKS), then you need to use a DOS session (or a VBScript "shell".Run). A bit more information can be found about the differences between scheduled "jobs" and "tasks" here: http://msdn2.microsoft.com/en-us/library/aa394399.aspx ....and this link also states that a "scheduled job" created using the Win32_ScheduledJob objet cannot be changed in the control panel "Scheduled Tasks" GUI. In my experience, confusingly and against what the documentation in the link above says, some jobs created with AT, can appear in the Scheduled Tasks control panel GUI, but as soon as you modify them using the GUI, then the AT command is no longer able to list/modify/execute/delete them, and Win32_ScheduledJob is no longer able to view them. Regards, Dave. <akkha1234@gmail.com> wrote in message news:1179354605.955081.313940@w5g2000hsg.googlegroups.com... > How do I kick off a scheduled task in a batch script? We can bring up > the scheduled tasks GUI interface, select a job and click run to run > the job direct. But can I do it via a batch job? > |
|
#4
| |||
| |||
| Re: How to run a scheduled task via a batch job
I didn't know about the schtasks command line. Curious, I tried schtasks /query and got back TaskName Next Run Time Status ==================================== ========= User_Feed_Synchronization-{024379B3- 23:12:00, 5/18/2007 User_Feed_Synchronization-{024379B3- 23:12:00, 5/18/2007 However, these tasks do not appear under control panel -> Scheduled Tasks. Is there any way to dope out the detail of these tasks and who (what process or user) scheduled them? Thank you, Fred Jacobowitz |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "How to run a scheduled task via a batch job" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Windows Scheduled Task: Unable to start task. 0x80070005: Access is denied. | BCU_AJones | Windows Software | 1 | 01-12-2011 11:49 PM |
| scheduled task never ends launchning a batch | PeterKou | Windows Server Help | 4 | 19-08-2010 06:31 PM |
| Scheduled task will not run as scheduled! | alex.birchall@gmail.com | Window 2000 Help | 1 | 03-12-2009 04:18 PM |
| Problems running batch file as scheduled task | pete0085 | Windows Server Help | 7 | 01-01-2009 03:15 PM |
| Scheduled Task error code:The task completed with an exit code of | Teo Chee Yang | Windows Server Help | 7 | 26-02-2007 06:01 PM |