Go Back   TechArena Community > Technical Support > Computer Help > Windows Server > Windows Server Help
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How to run a scheduled task via a batch job

Windows Server Help


Reply
 
Thread Tools Search this Thread
  #1  
Old 17-05-2007
akkha1234@gmail.com
 
Posts: n/a
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?


Reply With Quote
  #2  
Old 17-05-2007
Michael Harris \(MVP\)
 
Posts: n/a
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


Reply With Quote
  #3  
Old 17-05-2007
D.R.
 
Posts: n/a
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?
>



Reply With Quote
  #4  
Old 18-05-2007
Fred J.
 
Posts: n/a
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

Reply With Quote
Reply

  TechArena Community > Technical Support > Computer Help > Windows Server > Windows Server Help
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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 3 17-01-2014 10:37 AM
Scheduled Task does not run coreymac1222 Windows XP Support 3 06-03-2009 02:06 AM
Problems running batch file as scheduled task pete0085 Windows Server Help 7 01-01-2009 03:15 PM
Can't run scheduled task alicorn2 Windows Server Help 8 22-04-2008 05:07 AM
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


All times are GMT +5.5. The time now is 03:00 PM.