• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 35474
  • Last Modified:

Get PSEXEC to work with a list of computers

Hey Guys,

I'm sure you guys out there who have used psexec will be able to answer this one fairly easily.  I have written up a quick batch that allows me to run a utility remotely on computers over the network one at a time but I was looking to alter it so that the batch file could process a list of computers rather than one at a time.  I need to run this utility remotely on approximately 40 computers so you could see the one at a time becoming a tedious process.  I know PSEXEC is able to process a list but I can't seem to figure it out on my own and the /? from the command line is pretty confusing.

Again, the batch I have attached works fine, but it only works with the computername listed.  I need to figure out how to get it to work pulling from a list instead.  Anyone have any experience with this utility?
@echo off
net use \\COMPUTERNAME\c$ /user:"domain\username"
copy /y file.exe \\COMPUTERNAME\c$\file.exe
"c:\pstools\psexec.exe" \\COMPUTERNAME -i -w c:\ c:\file.exe
net use \\COMPUTERNAME\c$ /delete /y

Open in new window

1 Solution
Danny ChildIT ManagerCommented:
nappy_dThere are a 1000 ways to skin the technology cat.Commented:
Here it is below.  Save your script to a .bat file and run accordingly.

FOR /F %1 IN (c:\pathToFile\computers.txt) do c:\PathToBatchScript\script.bat (%1)

Open in new window

Try this:

The "File.exe" will have to be in the same location on your system for the copy to work.  Make sure that the folder where psexec is at as well as the location of your file are in the %System Path% and you should have no issues with this.

This example paths to a .csv, but a .txt will work just as well.
@echo off
psexec @C:\TEMP\list.csv -u MyDomain\Username -c c:\file.exe

Open in new window

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

crphdAuthor Commented:
FANTASTIC I don't know why I didn't try this before.  Works like a charm and such a simple command.  Thanks again everyone
nappy_dThere are a 1000 ways to skin the technology cat.Commented:
I think the author should review his answer acceptance.  He has a batch file that he wants run on multiple computers.  not a .exe file.


RE: "He has a batch file that he wants run on multiple computers.  not a .exe file."
The script I mentioned will do just that.


"psexec @C:\TEMP\list.csv" - This will start psexec and tell it to use this list of devices as opposed to a single device.

" -u MyDomain\Username" This will use the login ID specified, yet prompt for a password.  That's more secure than using the "-p PASSWORD" option.

" -c c:\file.exe" - This section copies the file.exe from the local machine to the remote machine so that psexec can use it.  Note:  It must be in the same path as where you copy it to; ie C:\temp\file.exe to C:\Temp\file.exe or C:\MyBatch.cmd to C:\MyBatch.cmd  This can be any kind of file as long as you can run it from a command line with no other pop-ups to click on, etc.

Hope that helps clear things up!
nappy_dThere are a 1000 ways to skin the technology cat.Commented:
yup..I was just having him call the batch file :)
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.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now