@echo off && setlocal enabledelayedexpansion set cd=%~dp0 cd /D %userprofile% if exist "restarts.bat" (goto restarts) else (goto start) :start set /a completed=0 echo How many times to restart? Type 'exit' to stop this from starting (if it doesn't automatically) set /p times= if %times% EQU exit goto stopped SET "var="&for /f "delims=0123456789" %%i in ("%times%") do set var=%%i if defined var (goto invalid) else (cls) choice /n /c:YN /m "Shutdown on end? Y/N" goto sd-%ERRORLEVEL% :sd-1 set /a sd=1 && goto sd-3 :sd-2 set /a sd=0 && goto sd-3 :sd-3 if exist "restarts.bat" ( del restarts.bat ) if not exist "restarts.bat" ( echo set rst=0 echo set times=%times% echo set sd=%sd% echo set cd=%cd% echo set completed=0 echo set continue=0 )>restarts.bat goto restarts :restarts call restarts.bat if %completed% EQU 1 goto start if %continue% EQU 1 set /a continue=0 && goto start if %times% LEQ 0 goto complete set /a rst=%rst%+1 set /a times=%times%-1 if %rst% gtr 1 set s=s echo You have restarted %rst% time%s% so far timeout 2 >nul ( echo set cd=%cd% echo start call "%cd%restartme.bat" )>"%appdata%\Microsoft\Windows\Start Menu\Programs\Startup\restarter.bat" call :save echo Shutdown in 5s... timeout 5 >nul shutdown /r /t 001 exit :complete del "%appdata%\Microsoft\Windows\Start Menu\Programs\Startup\restarter.bat" del "restarts.bat" echo Restarts complete! if %sd% EQU 0 echo You chose to not shutdown, closing && timeout 10 if %sd% EQU 1 echo You chose to shutdown && echo Close this window to cancel && timeout 30 && shutdown /s /t 001 exit :invalid cls echo Enter a number dummy -.- pause cls goto start :save ( echo set rst=%rst% echo set times=%times% echo set sd=%sd% echo set cd=%cd% echo set completed=%completed% echo set continue=%continue% )>restarts.bat exit /b :stopped cls echo Disabled, to enable just run this program again pause del restarts.bat "%appdata%\Microsoft\Windows\Start Menu\Programs\Startup\restarter.bat" :exit exit