Schedule Task within script RRS feed

  • Question

  • I am trying to create a task with very specific options:

    This is how I create it from a CMD line:

    schtasks /create /tn "Taskname" /tr "\"C:\Program Files\Program1\Program2\Start.exe\"/T" /sc daily /st 01:45:00 /ru "System"

    It seems quite complicated to use Set objNewJob = objWMIService.Get("Win32_ScheduledJob") -

    (for me anyway) so I was cheating and calling a CMD line but this doesn't work either.

    I'm guessing its the " but can't figure it out... 

    Set objShell = WScript.CreateObject ("") "cmd /c schtasks /create /tn "Taskname" /tr "\"C:\Program1\Program2\Start.exe\"/T" /sc daily /st 01:45:00 /ru "System""
    Set objShell = Nothing

    Any advice gratefully received.  

    • Edited by Qazxswe99 Saturday, August 2, 2014 1:53 PM
    Saturday, August 2, 2014 1:50 PM


All replies