:: -- This script require "Computers.txt" file on C: drive root
:: -- from where it will pick computer names.
:: -- shutdown all servers/pcs in the test file if
:: -- they respond to a ping request
:: --
:: -- Copy and Paste following script into notepad and save
:: -- it with any name having .cmd extension.
:: Batch Script Start
@Echo Off
SETLOCAL
IF NOT EXIST C:\Computers.txt Goto ShowErr
FOR %%F IN (c:\Computers.txt) Do IF %%~zF EQU 0 Goto ShowErry
FOR /F "delims=#" %%c IN ('Type C:\Computers.txt') Do call :SHUT %%c
Goto EndScript
:SHUT
echo processing %1
PING -n 2 -w 400 %1|Find /I "TTL" >NUL || echo %1 is switched off
REM reboot
IF %errorlevel% EQU 0 shutdown -r -f -m \\%1 -t 10
Goto :EOF
:ShowErr
Echo "C:\Computers.txt" file does not exist or file is empty!
:EndScript
ENDLOCAL
:EOF
|