Hi,
I'm trying to create a scheduled task from vbscript.
I've tested the following code:
but when I run the code, got the error code 2, and the task was not created.
I'm trying to create a scheduled task from vbscript.
I've tested the following code:
Code:
' Create a Scheduled Task
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
errJobCreated = objNewJob.Create _
("Notepad.exe", "********123000.000000-420", _
True , 1 OR 4 OR 16, , , JobID)
Wscript.Echo errJobCreated
but when I run the code, got the error code 2, and the task was not created.