Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Schedule Task within script

$
0
0

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.  





Viewing all articles
Browse latest Browse all 15028

Trending Articles