Skip to content

Instantly share code, notes, and snippets.

@keedi
Forked from aero/remote_exe.vbs
Created April 25, 2013 06:58
Show Gist options
  • Save keedi/5458002 to your computer and use it in GitHub Desktop.
Save keedi/5458002 to your computer and use it in GitHub Desktop.
'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