KXM Posted January 10, 2006 Posted January 10, 2006 (edited) So schtasks.exe just isn't cutting it for me any more... I need more power. But I can't seem to get the syntax quite right: $oComError_UDFGlobal = ObjEvent("AutoIt.Error", "__Generic_COM_Error") $strComputer = "." $objWMIService = ObjCreate("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") $JobID = "Test" $objNewJob = $objWMIService.Get("Win32_ScheduledJob") $errJobCreate = $objWMIService.Create ("C:\windows\Notepad.exe", "********143000.000000-420", True , 1 OR 4 OR 16, ,True, $JobId) If $errJobCreate = 0 Then MsgBox(0, '', "Job created successfully: Notepad.exe scheduled to run repeately at 14.30 (2:30 P.M.) PST on Mon, Wed, and Fri.") Else MsgBox(0, '', "Job not created. Error code = " & $errJobCreate) EndIf Func __Generic_COM_Error() Local $hNumber = Hex($oComError_UDFGlobal.number, 8) ;blantly stolen from SvenP (We'll call it a 'port') MsgBox(0, 'XZip Com Error', 'There was COM Error!' & @CRLF & @CRLF & _ 'description is: ' & @TAB & $oComError_UDFGlobal.description & @CRLF & _ 'windescription:' & @TAB & $oComError_UDFGlobal.windescription & @CRLF & _ 'number is: ' & @TAB & $hNumber & @CRLF & _ 'lastdllerror is: ' & @TAB & $oComError_UDFGlobal.lastdllerror & @CRLF & _ 'scriptline is: ' & @TAB & $oComError_UDFGlobal.scriptline & @CRLF & _ 'source is: ' & @TAB & $oComError_UDFGlobal.source & @CRLF & _ 'helpfile is: ' & @TAB & $oComError_UDFGlobal.helpfile & @CRLF & _ 'helpcontext is: ' & @TAB & $oComError_UDFGlobal.helpcontext _ ) SetError(1) EndFunc From this example: strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2") JobID = "Test" Set objNewJob = objWMIService.Get("Win32_ScheduledJob") errJobCreate = objNewJob.Create _ ("Notepad.exe", "********143000.000000-420", _ True , 1 OR 4 OR 16, ,True, JobId) If errJobCreate = 0 Then WScript.Echo "Job created successfully: " & VBNewLine _ & "Notepad.exe scheduled to run repeately at 14.30 (2:30 P.M.) PST" & VBNewLine _ & "on Mon, Wed, and Fri." Else WScript.Echo "Job not created. Error code = " & errJobCreate End If Any tips? TIA! Edited January 10, 2006 by KXM
Developers Jos Posted January 10, 2006 Developers Posted January 10, 2006 (edited) $objNewJob = $objWMIService.Get("Win32_ScheduledJob")$errJobCreate = $objNewJob.Create ("C:\windows\Notepad.exe", "********143000.000000-420", Edited January 10, 2006 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
KXM Posted January 11, 2006 Author Posted January 11, 2006 $objNewJob = $objWMIService.Get("Win32_ScheduledJob")$errJobCreate = $objNewJob.Create ("C:\windows\Notepad.exe", "********143000.000000-420",I am such a dumbass!!!THNX!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now