network remote shutdown batch files
Posted: Sun Jan 20, 2008 11:43 pm
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
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