3

I have few computers connected to the network and I want to create batch files to automatize the process of working with them. I have already created one used to shutdown computers at once. It is very simple I ll just post it for the sake of argument.

@echo off
shutdown -s -m \\Slave1-PC
shutdown -s -m \\Slave2-PC
shutdown -s -m \\Slave3-PC

Now I want to execute programs on these machines. So lets say there is "example.exe" file located "\Slave1-PC\d\example.exe"

using

 call \\Slave1-PC\\d\\example.exe

runs it on my computer through network and i didn't come up with anything else. I dont want to use any psexec if possible. Help would be much appreciated.

Peter

2
  • 1
    " I dont want to use any psexec if possible." Why not?
    – Joe
    Sep 22, 2012 at 17:18
  • I didn't want to use external libraries simply because it makes more sense to use existing easy to write "batch language". I wouldn't have to install anything on these computers as well ... In addition, I never worked with psexec, never tried to set it up so I would need to look at it and that costs time.
    – Peter Kottas
    Sep 22, 2012 at 19:25

2 Answers 2

3

If you really can't use psexec, then you could probably rig something up with schtasks (better) or at (worse).

However, I think you'd probably spend more time trying to get those to do what you want than you'd spend in setting up PsExec. Psexec is really quite simple to use and it only needs to be available (as an executable file; no installer needed) on the machine doing the controlling, not on each machine being controlled.

At its simplest, PsExec is very simple:

psexec -accepteula \\RemoteMachine Command Arguments

Also, Mark Russinovich (PsExec's author) has written a primer that "describes how PsExec works and gives tips on how to use it". Beyond that, "PsExec /?" and the manual do provide quite good information.

2
  • Strange, I thought that it would be really simple. Something like ... run_on_network \\Slave1-PC\\d\\example.exe . Since it is not, I have to look at Psexec I guess. I didn't even know that it only has to be on "Master_PC". That makes is simpler. Could you provide the code using psexec ?
    – Peter Kottas
    Sep 22, 2012 at 21:02
  • @peter With batch, it isn't that easy. With PowerShell, it is.
    – jscott
    Sep 22, 2012 at 22:48
1

PSEXEC is very easy and simple to use. You use it basically in the same way you use CALL or START (except you give it the target computer and a username and password if needed), and is capable of even launching GUI applications, though you won't be able to see or control it.

When used to launch a command-line program with normal STDIN / Console input and STDOUT and STDERR output, the program or batch file will act as if you are simply running it on your own machine.

I was up and using PSEXEC to run diagnostics, defrag.exe, anti-virus programs, and for gathering system information in a shop with over 2,000 PC's without more introduction than PSEXEC /? within a day.

Run:

PSEXEC \\COMPUTER -u Administrator -p password CMD.exe

And you've got the same interactive Command Prompt on COMPUTER that you'd have if you walked over and typed ALT+RCMDENTER. Maybe a little slower, but it's not noticeable unless you're scrolling through a massive amount of text. Even over 10 Base-T it's not too bad.

As an Network Administrator able to use the same username / password on nearly every computer, I found that all but the most locked down computers, I didn't even need to use a username or password. This...

PSEXEC \\COMPUTER CMD

...was usually sufficient.

To use your example type:

psexec \\Slave1-PC d:\example.exe

Or:

psexec \\Slave1-PC cmd
d:
example

PSEXEC will prompt you for a username and password if they are needed.

The first time you connect to a computer you may need to (or get someone else to) allow the connection via a Pop-Up on the remote system.

Download it Here

Learn about it Here

You must log in to answer this question.