Get PSEXEC to work with a list of computers

Posted on 2009-02-16
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



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

Question by:crphd
    LVL 23

    Expert Comment

    LVL 32

    Expert Comment

    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

    LVL 7

    Accepted Solution

    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

    LVL 1

    Author Closing Comment

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

    Expert Comment

    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.
    LVL 7

    Expert Comment



    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!
    LVL 32

    Expert Comment

    yup..I was just having him call the batch file :)

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    There are 2 things you must have in order to connect to the internet behind a router, The "Gateway IP" of the router, which is usually something like, I've seen routers with default values of:,,, …
    Can you find a fax from a vendor you saved a decade ago in seconds? Have you ever cursed your PC under your breath during an audit because you couldn’t find the requested statement or driver history?  If you answered no to the first question or yes …
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now