1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| @echo off & cls
setLocal EnableDelayedExpansion
set current_path=%~dp0
set current_path_modified=%current_path:~0,-1%
set list=ComputersToShutdown
set numberofcomputers=226
set baseIP=9.27.185.
if not exist "%current_path_modified%\ComputersToShutdown\" md "%current_path_modified%\ComputersToShutdown\"
if exist "%current_path_modified%\ComputersToShutdown\%list%.txt" del /F /S /Q "%current_path_modified%\ComputersToShutdown\%list%.txt"
FOR /L %%i IN (1,1,%numberofcomputers%) DO (
ECHO %baseIP%%%i>>"%current_path_modified%\ComputersToShutdown\%list%.txt"
)
for /f "tokens=*" %%a in (%current_path_modified%\ComputersToShutdown\%list%.txt) do (
title Ping en cours sur %%a
set nom=%%a
set /a N+=1
set v!N!=%%a
ping !nom! -n 1 -w 100 -4 -l 8 > nul
if not errorlevel 1 (
set /A compteur+=1
set v!compteur!=%%a
echo !nom! est allume, on le shutdown
call :Shutdown !nom!
)
if errorlevel 1 (
echo !nom! est eteind
)
)
:Shutdown
if not "%1"=="" (
title Shutdown en cours sur %1
echo Shutdown en cours sur %1
echo shutdown /h \\%1 /t 0 /s /f
echo Shutdown effectue sur : %1
goto :Exit
) else (
echo ERREUR!
goto :Exit
)
:Exit
pause
exit |
Partager