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?
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?
[email protected] 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
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.
<[email protected]> wrote in message
news:[email protected]...
> 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?
>
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
Bookmarks