batch file

JIGYANSHA1985
StarLounger
Posts: 77
Joined: 15 Jan 2011, 02:32

batch file

Post by JIGYANSHA1985 »

Sir,
Is there any batch file (.bat extension) after running which more than one computer shall be shutting down, if running within a Local Area Network. So, that I don't have to shutting down all computer one by one...

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15617
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: batch file

Post by ChrisGreaves »

JIGYANSHA1985 wrote:Is there any batch file (.bat extension) after running which more than one computer shall be shutting down, if running within a Local Area Network. So, that I don't have to shutting down all computer one by one...
I'm not sure what you mean.
I have a set of batch files which run (perform backups to multiple external drives) on each of several machines on a LAN.
One batch file determines what should be done at the end of the run.
On one machine the machine should be shut down.
On another machine, that machine should be rebooted.
On a third machine, that machine should just continue running.

Typical use would be a small office where everyone knocks off and goes home at a different time, but start the backup job (on their own machine) running before they leave. The batch job(s) wait until the external drives are available, then all machines issue their backup commands and then, as outlined above, each machine terminates its backup process in a different way.
There's nothing heavier than an empty water bottle

JIGYANSHA1985
StarLounger
Posts: 77
Joined: 15 Jan 2011, 02:32

Re: batch file

Post by JIGYANSHA1985 »

I want that if on my machine I run the batch file it will shutting down my machine. Another batch file shall shut down not only mine but rest of the machines.

User avatar
John Gray
PlatinumLounger
Posts: 5408
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: batch file

Post by John Gray »

For what it's worth, here is my Shutter BATch file:

Code: Select all

@echo off
title Shut down active PCs, with the exception of PC22, PC30, PC25 and PC26
echo +---------+
echo I Shutter I  Shut down active PCs, except  PC22, PC30, PC25 and PC26
echo +---------+
::                                            John Gray  14SEP2005,10JAN2010
:: uses XP built-in command SHUTDOWN
:: could use SysInternals' PSSHUTDOWN

setlocal
:: list the PCs to be shut down       <--   O M I T T E D   -->
::                                    22       25 26         30
set pcnums=06 13 14 15 16 17 18 20 21    23 24       27 28 29   31 32 33
for %%a in (%pcnums%) do call :process %%a
echo %~n0: complete.
:: wait for ten seconds before exiting
ping -n 11 127.0.0.1 > nul
endlocal
goto :eof
::-------------------------------------------------------------------------
:process each PC number in turn, passed as %1
set pcname=PC%1
:: firstly see whether the PC is active
::   try to wake the device up, then look for "TTL=" as positive response
ping -n 1 %pcname% > NUL & ping -n 1 %pcname% | findstr "TTL=" > NUL
if %errorlevel% EQU 0 goto do_shut
echo %~n0: %pcname% is not active, and has probably already been shut down
goto :eof

:do_shut
echo %~n0: %pcname% shows as active, and will be shut down now
shutdown -s -f -m \\%pcname% -t 0
:: we COULD wait for each PC to be shut down, but we don't
goto :eof
Obviously this will require an amount of work to customise it to your own installation's requirements.
John Gray

"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...