Remote Shutdown Batch File

D

DavidB

I use the "shutdown \\computername" command within a batch
file to remotely restart all the machines in our office.
If a user shuts down their machine and the batch file is
ran, the batch file hangs when it encounters the machine
that's shutdown. This use to not happen under NT. We're
currently using Windows 2000 SP-4. is there any way to
avoid this?
 
G

Guest

Maybe pinging the computer before issuing the shutdown ...

Assuming the env variable 'Machine' contains the name of
the machine that is to be tested, something like this
might work for you ...

ping -n 1 %Machine% | find "TTL=" > nul && (
shutdown \\%Machine%)

Tom Lavedas
===========
 
R

Ray at

Does it hang forever? I've tried to shutdown machines that were already off
before, and it'll eventually indicate that it couldn't connect and move on.
You could loop through a 'net view' and shut down those machines to avoid
this slow down most of the time.

Ray at work
 
D

DavidB

I run this batch file at night using the task scheduler.
If Phil could give an example of some code that would
first test weather a machine is on. If so, perform the
shutdown command, else go to the next line in my batch
file. Any help on this would be greatly appreciated.
David B
 
D

DavidB

It worked great! Thanks Tom
-----Original Message-----
Maybe pinging the computer before issuing the shutdown ...

Assuming the env variable 'Machine' contains the name of
the machine that is to be tested, something like this
might work for you ...

ping -n 1 %Machine% | find "TTL=" > nul && (
shutdown \\%Machine%)

Tom Lavedas
===========


.
 
M

Matthias Tacke

DavidB said:
I run this batch file at night using the task scheduler.
If Phil could give an example of some code that would
first test weather a machine is on. If so, perform the
shutdown command, else go to the next line in my batch
file. Any help on this would be greatly appreciated.
David B

If you use shutdown from NT reskit, there might be differences.
Reskit for w2k isn't free, the one for w2k3 seens to be.

An superior alternative to shutdown is psshutdown from:
http://www.sysinternals.com/ntw2k/freeware/psshutdown.shtml
Except from redistribution its free.
I just tested the behavior for computer off the power in w2ksp4.
I get an errormessage "Couldn't access COMPUTERNAME"

hth
 
J

Jens Hastrup

DavidB said:
I run this batch file at night using the task scheduler.
If Phil could give an example of some code that would
first test weather a machine is on. If so, perform the
shutdown command, else go to the next line in my batch
file. Any help on this would be greatly appreciated.
David B

Hi David

One approach that would work...

ping -n 1 somecomputer >nul && shutdown \\somecomputer

Jens
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top