We help IT Professionals succeed at work.

Get PSEXEC to work with a list of computers

crphd
crphd asked
on
Medium Priority
42,030 Views
Last Modified: 2012-08-13
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
 
c:
cd\
 
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

Comment
Watch Question

Irwin W.There are a 1000 ways to skin the technology cat.
CERTIFIED EXPERT

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

Commented:
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

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
Irwin W.There are a 1000 ways to skin the technology cat.
CERTIFIED EXPERT

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.

Commented:
@nappy_d:

Hola!

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.

See,

"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!
=)
Irwin W.There are a 1000 ways to skin the technology cat.
CERTIFIED EXPERT

Commented:
yup..I was just having him call the batch file :)
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.