Windows, Execute process on Remote PC

Even need to run a batch on another computer remotely. How about install patches or even just configure an IP address. Here is a script that will allow you to execute a process on a remote PC, given that you have access.

Option Explicit
Dim objWMIService, objProcess
Dim strShell, objProgram, strComputer, strExe, strInput
strExe = "Calc.exe"
‘ Input Box to get name of machine to run the process
strComputer = (InputBox(" ComputerName to Run Script",_
"Computer Name"))
If strComputer <> "" Then
strInput = True
End if
Loop until strInput = True
‘ Connect to WMI
set objWMIService = getobject("winmgmts://"_
& strComputer & "/root/cimv2")
‘ Obtain the Win32_Process class of object.
Set objProcess = objWMIService.Get("Win32_Process")
Set objProgram = objProcess.Methods_( _
objProgram.CommandLine = strExe
‘Execute the program now at the command line.
Set strShell = objWMIService.ExecMethod( _
"Win32_Process", "Create", objProgram)
WScript.echo "Created: " & strExe & " on " & strComputer
‘ End of Example of a Process VBScript

imageIf you want you can change the script so that you can send the Process name and the PC via an Argument. Don’t forget to run is with cscript if you wish to have the Echo’s go to console.

This entry was posted in Mircosoft, Secuirty. Bookmark the permalink. Trackbacks are closed, but you can post a comment.

Post a Comment

Your email is never published nor shared. Required fields are marked *


  • Welcome to