How to create batch file using Psexec to install .msi on more than one computer?

hi guys

I've successfully been using the below batch file to install msi files on remote computers:

c:\psexec.exe \\remotecomputer -u Domain\Username -p Password msiexec.exe /i "\\networkservername\sharename\my.msi" /quiet /norestart

However, that's just for one PC. How can I do this, so that the installation takes place on multiple machines?

Thank you
Who is Participating?
Just the names, no leading backslashes.
And for the fun of it, here's the version if you're not reasonably sure about the machines being online; it tries to ping them and creates a log file with the results. The script is in test mode and will only display the psexec commands it would normally run; remove the uppercase ECHO in line 12 to run it for real.
@echo off
setlocal enabledelayedexpansion
set MachineFile=C:\Temp\machines.txt
set LogFile=C:\Temp\machines.csv
>"%LogFile%" echo "Machine","State","Errorlevel"
for /f %%a in ('type "%MachineFile%"') do (
	echo Processing %%a ...
	ping.exe -4 -n 2 %%~a | find /i "TTL" >NUL
	if errorlevel 1 (
		>>"%LogFile%" echo "%%~a","Offline","n/a"
	) else (
		ECHO c:\psexec.exe \\%%~a -u Domain\Username -p Password msiexec.exe /i "\\networkservername\sharename\my.msi" /quiet /norestart
		>>"%LogFile%" echo "%%~a","Online","!ErrorLevel!"
echo Done.

Open in new window

If you're reasonably sure the target machines are all online, prepare a file with the machine names (one name per line) and simply replace \\remotecomputer with @"C:\Temp\machines.txt" (or wherever you placed the file):
c:\psexec.exe @"C:\Temp\machines.txt" -u Domain\Username -p Password msiexec.exe /i "\\networkservername\sharename\my.msi" /quiet /norestart

Open in new window

YashyAuthor Commented:
Aha, I see. That's fantastic man, thank you!!

So in the machines.txt file, should I do this:


and so on?
YashyAuthor Commented:
I don't even know what to say to that!

Now that's what I call giving an answer way above and beyond, fantastic stuff man. Really appreciate it.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.