Listing 1: Excerpt from GroupedShutdowns.bat Set P1cntr=0 Set P2cntr=0 Set Skippoint=%1 If Not '%Skippoint%'=='' Goto :Skip%Skippoint% BEGIN CALLOUT A Call :PreTest 1 :Skip1 Call :T1 1 :Skip2 Call :Test1 2 :Skip3 Call :T2 2 :Skip4 Call :Test2 3 :Skip5 Call :Uptime END CALLOUT A Echo Run completed - inspect %UptimeLog% log file to verify uptime info. Pause Goto :EOF :PreTest :Test1 :Test2 Set fail=0 BEGIN CALLOUT B If %1 EQU 1 Echo Running pre ping test now & For /F "usebackq tokens=2 delims=," %%i in (%ServerList%) Do (Set Server=%%i) & (Call :Ping) END CALLOUT B If %1 EQU 2 Echo Running group one ping test now & For /F "tokens=2 delims=," %%i in ('Findstr "1," "%ServerList%"') Do (Set Server=%%i) & (Call :Ping) If %1 EQU 3 Echo Running group two ping test now & For /F "tokens=2 delims=," %%i in ('Findstr "2," "%ServerList%"') Do (Set Server=%%i) & (Call :Ping) BEGIN CALLOUT C If %1 EQU 1 If %fail% EQU 1 Echo Pretest Failure! Please check above non-pingable node & Pause & Exit END CALLOUT C If %P1cntr% GTR 4 Echo Repeated Failure! Please check above non-pingable group one node & Pause & Exit If %P2cntr% GTR 4 Echo Repeated Failure! Please check above non-pingable group two node & Pause & Exit If %1 EQU 2 If %fail% EQU 1 Set /A P1cntr+=1 & Echo Waiting 60 extra seconds for all group one nodes to come online & Sleep 60 & Call :Test1 2 If %1 EQU 3 If %fail% EQU 1 Set /A P2cntr+=1 & Echo Waiting 60 extra seconds for all group two nodes to come online & Sleep 60 & Call :Test1 3 Goto :EOF :Ping Set response= For /f "tokens=1" %%i in ('Ping -n 1 %Server%^|Findstr /I /C:"Reply from"') Do (Set response=%%i) & (@Echo %Server% online) If Not '%response%'=='Reply' @Echo %Server% offline & Set fail=1 Goto :EOF BEGIN CALLOUT D :T1 :T2 For /F "tokens=2 delims=," %%i in ('Findstr "%1," "%ServerList%"') Do (Set Server=%%i) & (Call :Proceed) Echo Waiting for %TimeOut% seconds... Sleep %TimeOut% Goto :EOF :Proceed Echo Issuing shutdown command to %Server% Shutdown -r -f -m \\%Server% -t 120 -c "Server %Server% will be shutting down in two minutes for a regularly scheduled reboot - Please save your work now." Goto :EOF END CALLOUT D BEGIN CALLOUT E :Uptime Echo Group 1 >"%UptimeLog%" For /F "tokens=2 delims=," %%i in ('Findstr "1," "%ServerList%"') Do uptime.exe %%i>>"%UptimeLog%" Echo.>>"%UptimeLog%" Echo Group 2 >>"%UptimeLog%" For /F "tokens=2 delims=," %%i in ('Findstr "2," "%ServerList%"') Do uptime.exe %%i>>"%UptimeLog%" Goto :EOF END CALLOUT E