The following code doesn't work for me.
Const HIDDEN_WINDOW = 0
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
&;; "{impersonationLevel=impersonate}!\\" _
&;; strComputer &;; "\root\cimv2")
Set objStartup = objWMIService.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
objConfig.ShowWindow = HIDDEN_WINDOW
Set objProcess = GetObject( _
"winmgmts:root\cimv2:Win32_Process")
errReturn = objProcess.Create( _
"Notepad.exe", null, objConfig, intProcessID)
I added a line to the end:
WScript.Echo errReturn
It gives a return code of 3.
If this follows Microsoft Error Codes correctly, this means that the error is:
The system cannot find the path specified.
This works on other machines. I am not sure the issue.
Notepad.exe is in the path.
I do have a P:\ as my default directory if I open a command prompt. Could that be the issue. How can the script be modified to handle this.
Also, this script would be much more useful if it accepted a parameter that was the executable.