Without using PowerShell, here’s an “old school” batch file script method of running a simple “For Loop” against multiple computers over a network. As an example, my batch file includes a program called “PsExec” from Windows Sysinternals. However, you could also use this simple batch file script with other programs such as Microsoft’s Robocopy or even xcopy.exe. I think that you’ll find these few lines of code very applicable even in today’s computing environment. Moreover, the Information Technology derivation of Occam’s razor, should one exist, probably states that when you have two competing tech solutions that produce exactly the same results, the simpler one is better. You heard it first at the Caged Rat!
Install Adobe Flash on Multiple Computers
PsExec Download and Setup
- Download PsExec @ Windows Sysinternals
- Extract the PSTools.zip file to your c: drive
- Update your environment system variable “Path” with the location of the PSTools folder:
@ECHO OFF REM This Batch Script uses a For Loop command to REM run commands against multiple computers over the network. REM Right-click on your batch file and click on REM "Run as administrator" REM PsExec uses "-h" to run commands with elevated REM privileges due to Windows User Access Control (UAC). For /f %%i in (c:\computers.txt) do ( Echo ************************ Echo %%i Echo ************************ psexec \\%%i –h –u domain\username) -p password "enter commands for PsExec here" ) pause
Author’s Tip: You can avoid the PsExec EULA (End User License Agreement) pop-up by adding the following “-accepteula” parameter in your script:
psexec \\%%i -accepteula –h –u domain\username) -p password "enter commands for PsExec here"
The contents of your text file containing computer names (.e.g., computers.txt) should be like the following: