Skip to content

Instantly share code, notes, and snippets.

@aero
Created September 29, 2011 08:20
Show Gist options
  • Save aero/1250270 to your computer and use it in GitHub Desktop.
Save aero/1250270 to your computer and use it in GitHub Desktop.
Create process via Windows WMI
'How to use -> cscript remote_exe.vbs hostname "cmd /c dir"
strComputer = Wscript.Arguments(0)
strCommand = Wscript.Arguments(1)
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
errReturn = objWMIService.Create( strCommand , Null, Null, intProcessID )
Select Case errReturn
Case 0 WScript.Echo "Command successfully completed " & "Process ID: " & intProcessID
Case 2 WScript.Echo "Access Denied"
Case 3 WScript.Echo "INsufficient Privilege"
Case 8 WScript.Echo "Unknown Failure"
Case 9 WScript.Echo "Path not found"
Case 21 WScript.Echo "Invalid Parameter"
End Select
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment