I have a script to schedule a task to run on a machine with a random time of the day that was defined with a variable, but I cannot concatenate the strings in the command line syntax for the WMI task scheduler. The code is listed below:
Const MONDAY = 1
Const TUESDAY = 2
Const WEDNESDAY = 4
Const THURSDAY = 8
Const FRIDAY = 16
Const SATURDAY = 32
Const SUNDAY = 64
Const EST = -300
Const CST = -360
Const MST = -420
Const PST = -480
strHour = 055400 'This time may vary.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
errJobCreated = objNewJob.Create _
("Notepad.exe", "********" & strHour & ".000000-" & CST, _ True , 1 Or 4 Or 16, , , JobID)
WScript.Echo errJobCreated
When I run this script, I get the error "SWbemObjectEx: Type mismatch."
Any help with this concatenation problem will be greatly appreciated.
Thanks!
Const MONDAY = 1
Const TUESDAY = 2
Const WEDNESDAY = 4
Const THURSDAY = 8
Const FRIDAY = 16
Const SATURDAY = 32
Const SUNDAY = 64
Const EST = -300
Const CST = -360
Const MST = -420
Const PST = -480
strHour = 055400 'This time may vary.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
errJobCreated = objNewJob.Create _
("Notepad.exe", "********" & strHour & ".000000-" & CST, _ True , 1 Or 4 Or 16, , , JobID)
WScript.Echo errJobCreated
When I run this script, I get the error "SWbemObjectEx: Type mismatch."
Any help with this concatenation problem will be greatly appreciated.
Thanks!