Results 1 to 4 of 4

Thread: How to run a scheduled task via a batch job

  1. #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. #2
    Michael Harris \(MVP\) Guest

    Re: How to run a scheduled task 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



  3. #3
    D.R. Guest

    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.




    <[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?
    >




  4. #4
    Fred J. Guest

    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


Similar Threads

  1. Replies: 3
    Last Post: 17-01-2014, 10:37 AM
  2. Scheduled Task does not run
    By coreymac1222 in forum Windows XP Support
    Replies: 3
    Last Post: 06-03-2009, 02:06 AM
  3. Problems running batch file as scheduled task
    By pete0085 in forum Windows Server Help
    Replies: 7
    Last Post: 01-01-2009, 03:15 PM
  4. Can't run scheduled task
    By alicorn2 in forum Windows Server Help
    Replies: 8
    Last Post: 22-04-2008, 05:07 AM
  5. Scheduled Task error code:The task completed with an exit code of
    By Teo Chee Yang in forum Windows Server Help
    Replies: 7
    Last Post: 26-02-2007, 06:01 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,123,555.83917 seconds with 16 queries