How to run a command remotely on computers

You can use PSExec.exe from Microsoft to run a command remotely. PSExec.exe is part of PSTools from Microsoft which can be downloaded from here:

This tip shows how you can run a command remotely without using PSExec.exe.

Let’s say you want to run GPUpdate.exe command on a remote computer to refresh the GPO settings, use the below command:

  • WMIC /node:ComputerName process call create “cmd.exe /c GPUpdate.exe”

The above command creates a process on the remote computer to execute “cmd.exe /c GPUpdate.exe” command line.

You can utilize above command to run any command remotely. You just need to replace ComputerName and “cmd.exe /c GPUpdate.exe” with a choice of your command!

About Nirmal Sharma

Nirmal is a MCSEx3, MCITP and was awarded Microsoft MVP award in Directory Services. He is specialized in Directory Services, Microsoft Clustering, Hyper-V, SQL and Exchange and has been involved in Microsoft Technologies since 1994. In his spare time, he likes to help others and share some of his knowledge by writing tips and articles. Nirmal can be reached at [email protected].

About The Author

6 thoughts on “How to run a command remotely on computers”

  1. Then you simply specify the full path :

    WMIC /node:ComputerName process call create “cmd.exe /c c:\path-to-your-exe\GPUpdate.exe”

  2. I tried to open Firefox on a remote server using the following code but I receive a ReturnValue = 9. Firefox never launches.

    WMIC.exe /node:ComputerName process call create “cmd.exe/C C:\Program Files\Mozilla Firefox\firefox.exe”

  3. It works but it puts the application in the background and I can’t see the window… (just the process in the task manager) (it’s a computer where I’m logged in remotely)

    how can I put the window in front of everything?.. I’m trying with notepad

  4. You help is greatly appreciated,

    I am executing Test.bat file on remote server Server_2 from Server_1. Here’s portion of WMIC command on Server_1 – “cmd.exe /c \\Server_2\testDir\Test.bat”.

    Test.bat has exit %errorlevel%

    How can I capture %errorlevel% on Server_1? I would like to exit calling script on Server_1 with %errorlevel% returned from remote server Server_2.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top