locked
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 ("WScript.shell")
    objShell.run "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

Answers

  • Have a look at the thread created by saikrishna_n. It is adjacent to yours.
    • Marked as answer by Qazxswe99 Saturday, August 2, 2014 2:32 PM
    • Unmarked as answer by Qazxswe99 Saturday, August 2, 2014 2:32 PM
    • Proposed as answer by Mike Laughlin Sunday, August 3, 2014 1:03 AM
    • Marked as answer by ScriptingWife Tuesday, September 16, 2014 7:18 PM
    Saturday, August 2, 2014 2:22 PM

All replies

  • Have a look at the thread created by saikrishna_n. It is adjacent to yours.
    • Marked as answer by Qazxswe99 Saturday, August 2, 2014 2:32 PM
    • Unmarked as answer by Qazxswe99 Saturday, August 2, 2014 2:32 PM
    • Proposed as answer by Mike Laughlin Sunday, August 3, 2014 1:03 AM
    • Marked as answer by ScriptingWife Tuesday, September 16, 2014 7:18 PM
    Saturday, August 2, 2014 2:22 PM
  • Thank you again
    Saturday, August 2, 2014 2:32 PM