?
Solved

Get PSEXEC to work with a list of computers

Posted on 2009-02-16
7
Medium Priority
?
31,269 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

0
Comment
Question by:crphd
7 Comments
 
LVL 23

Expert Comment

by:Danny Child
ID: 23655167
0
 
LVL 32

Expert Comment

by:nappy_d
ID: 23655668
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

0
 
LVL 7

Accepted Solution

by:
ednetman earned 1000 total points
ID: 23661433
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

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Closing Comment

by:crphd
ID: 31547574
FANTASTIC I don't know why I didn't try this before.  Works like a charm and such a simple command.  Thanks again everyone
0
 
LVL 32

Expert Comment

by:nappy_d
ID: 23663299
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.
0
 
LVL 7

Expert Comment

by:ednetman
ID: 23663549
@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!
=)
1
 
LVL 32

Expert Comment

by:nappy_d
ID: 23663695
yup..I was just having him call the batch file :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Can I legally transfer my OEM version of Windows to another PC?  (AKA - Can I put a new systemboard in my OEM PC?) Few of us are both IT and legal experts but we all have our own views of Microsoft's licensing rules and how they apply.  There are…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question