Send Multiple Remote Desktop Sessions A Command

2

0

I use Microsoft's Remote Desktop Connection Manager to administer users on my network. I am looking for a way, or another program, that will allow me to send a command to all of my logged in remote connections at once. So if I am connected to 10 PCs, I can send them all a command to run a batch file, or maybe start a program. Something like \\server\folder\run.bat.

Anyone have any advice?

David

Posted 2015-06-08T15:30:27.067

Reputation: 23

Questions: 1) Do I correctly assume the list of computers you're remotely connected to could be different at any given time? 2) Would you be able to come up with a list of the computers to which you wanted to send the command without involving the RDP Manager? – I say Reinstate Monica – 2015-06-08T17:30:23.633

Yes, the computers could be different. And Yes, I could generate a list of computers that I wanted the command send to. – David – 2015-06-08T17:41:20.763

Are the computers on the same LAN or on different networks? Also, do you have Administrative level access to the computers? – I say Reinstate Monica – 2015-06-08T17:44:51.820

They are on the same domain, on the same LAN, and yes, I would be logged in as domain admin. – David – 2015-06-08T17:48:20.077

Answers

0

You can execute the same command simultaneously on multiple computers using PSEXEC.EXE from Microsoft's SysInternals toolkit. To run a command on multiple remote computers:

  1. Create the text file PCNAMES.TXT
  2. Put the remote computer names in the text file, one per line
  3. Run PSEXEC.EXE using the following syntax:
    PSEXEC.EXE @PCNAMES.TXT -s Command_To_Run.exe

This will run Command_To_Run.exe in the context of the remote computer's SYSTEM account and it assumes the executable is in the system path on the remote machine.

PSEXEC command line options relevant to your situation:

-c         Copy the specified program to the remote system for execution. If you omit this
           option the application must be in the system path on the remote system.
-d         Don't wait for process to terminate (non-interactive).
-u         Specifies optional user name for login to remote computer.
-p         Specifies optional password for user name. If you omit this you will be prompted
           to enter a hidden password.
-s         Run the remote process in the System account.  The remote command will only
           have access to local resources on the remote computer.

Examples:

  1. Copy Command_To_Run.exe from your local computer to the remote PC (-c switch) then execute it there:
    PSEXEC.EXE @PCNAMES.TXT -c Command_To_Run.exe

  2. Use a different user account/password (-u and -p switches) to run the remote command. Useful when accessing network resources from the remote PC:
    PSEXEC.EXE @PCNAMES.TXT -u UserName -p Password Command_To_Run.exe

I say Reinstate Monica

Posted 2015-06-08T15:30:27.067

Reputation: 21 477

To get PSEXEC.EXE to work, I had to running the command prompt as the domain admin. Holding shift + Right click on the CMD launcher, and selecting run as different user. – David – 2015-06-08T19:24:35.697