Bonjour
Mettre en paramètre de ce script le service à redémarrer
Comme vous le constatez il y a 5 tentatives pour vérifier que le service est RUNNING (des fois certains services sont un peu long lol)
echo off REM NOM du SERVICE %1% echo %USER% net start %1% for /F "tokens=4 delims=, " %%H in ('sc query %1% ^| findstr " STATE"') do ( if /I "%%H" NEQ "RUNNING" ( goto:NOTRUNNING ) else ( @echo Service %1% is running exit /b 0 ) ) :NOTRUNNING set /a "x = 0" :while1 echo Service %1% is not running %x% try timeout 10 sc query %1% | findstr RUNNING set RETCODE=%ERRORLEVEL% if %RETCODE% equ 0 goto END echo Servive %1% is not Running if %x% leq 5 ( set /a "x = x + 1" goto :while1) if %RETCODE% neq 0 ( echo Issue with starting sc query %1% exit /b 19) :END echo Service is Running echo End of job