There are several ways to execute a command on remote computers. You can use PSExec.exe, Windows PowerShell PSRemoting, and any other freeware tool which supports executing a command remotely. Most of the Windows Administrators do not know that there is a built-in tool available, called WMIC, to execute “any” command on the remote computers. WMIC, known as “Windows Management Instrumentation Command-line” is a WMI scripting interface that allows you to access WMI data on local or remote computers from Command Prompt.
Let’s assume, you want to update Group Policy Settings on a remote computer by using GPUpdate.exe. If you need to update GPO settings for one computer, use this command:
WMIC /node:Computer_Name process call create “cmd.exe /c GPUpdate.exe”
Since WMIC does not support executing commands on multiple computers, you need to use FOR loop as shown in the below command:
FOR /F “Tokens=*” %L IN (Computers.TXT) DO WMIC /node:%L process call create “cmd.exe /c GPUpdate.exe”
You can replace “cmd.exe /c GPUpdate.exe” with a choice of your command. Here is an example of stopping a service on a remote computer:
WMIC /node:Computer_Name process call create “Net Stop service_name”
The above tip was previously published in an issue of WServerNews, a weekly newsletter from TechGenix that focuses on the administration, management and security of the Windows Server platform in particular and cloud solutions in general. Subscribe to WServerNews today by going to http://www.wservernews.com/subscribe.htm and join almost 100,000 other IT professionals around the world who read our newsletter!
Mitch Tulloch is a twelve-time recipient of the Microsoft Most Valuable Professional (MVP) award and a widely recognized expert on Windows Server and cloud computing technologies. Mitch is also Senior Editor of WServerNews. For more information about him see http://www.mtit.com.