Page 1 of 1

network remote shutdown batch files

Posted: Sun Jan 20, 2008 11:43 pm
by mike pittenger
I am new to scripting and batch files in general. My goal is to shutdown a network of 2000 or so computers. I want to ping before shutting down to avoid a delay.

The first batch file (shutdown_list)will have the names of the computers and run the second batch file (shutdown_single)with the ping and shutdown.exe.

The problem I am having is the second batch file will not pick up the computer names from the first.

Any help will be appreciated.

shutdown_list.bat:

shutdown_single ad-dao-bm-03.casd
shutdown_single ad-dao-bm-04.casd
shutdown_single ad-dao-bm-05.casd

shutdown_single.bat:

@echo off
MachineName=%1
ping -n 1 -w 800 %MachineName%if not errorlevel 1 goto MachineOKecho Cannot ping machine %MachineName%. Aborting.goto Fini:MachineOK
shutdown.exe -s -f -m %MachineName% -t 60 -c "Daily shutdown, please save any work and shut down again if restarted."
:Fini

network remote shutdown batch files

Posted: Tue Jan 22, 2008 1:30 am
by jhicks
Change MachineName=%1toset MachineName=%1Or forgo adding another variable and simply use %1 instead of %machinename%

network remote shutdown batch files

Posted: Wed Apr 16, 2008 6:46 pm
by imperialxt
hey i'm rather new to this stuff i'm still a studentbut i'm curious if there is a way that i can get my shutdown bat file to prompt for which computer on the network i want to shutdown so it would like pop up and say insert name of computer and i would type "Computer1"any suggestions?

network remote shutdown batch files

Posted: Wed Apr 16, 2008 11:34 pm
by imperialxt
thanks that will come in handy i'm sure. I'm very interested in this type of scripting aka vbs any suggestions as to where a good place to learn it might be ?.

network remote shutdown batch files

Posted: Thu Apr 17, 2008 3:17 am
by imperialxt
thanks that looks like it will be very good :Palso is there a slight addition i can make to the script that will make it shutdown all computers ? or do i need to list all the computers as above ?

network remote shutdown batch files

Posted: Wed May 26, 2010 11:49 pm
by felimclarke
Hey,

Sorry to bother you but I am having a few problems with the script/batch file listed above if you could maybe point me in the right direction to getting to working please. I can get it working in on the 1st computer in the list but then it finishes running it doesn't move on to the next PC in the list.

As with mike

network remote shutdown batch files

Posted: Thu May 27, 2010 12:34 am
by jvierra
Try this:



for /F %i in (servers.txt) do
shutdown.exe -s -f -m %i -t 60 -c "Daily shutdown, please save any work and shut down again if restarted."



All on one line.

If in a batch file use double % signs.