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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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?
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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.