I wanted to write a simple batch script to shutdown my own computer which will be used when I'm in bed watching a DVD or something.
UPDATE: fixed the code, any other suggestions?
setlocal
@echo off & break off
:input
set /p "minutes=Enter number of minutes to wait until shutdown: "
set "numcheck="&for /f "delims=0123456789" %%i in ("%minutes%") do set "numcheck=%%i"""
if defined numcheck (
echo ERROR: Sorry "%minutes%" is not numeric, please try again & echo.
goto input
)
if %minutes% gtr 315360000 (
echo ERROR: Sorry your input is greater then 10 years, I can't handle that & echo.
goto input
)
set /a "seconds=%minutes%*60"
shutdown.exe /s /f /t "%seconds%"
if errorlevel 1 (
echo ERROR: Could not set shutdown, try again & echo.
goto input
)
:abort
set /p "continue=Your computer is about to shutdown in %minutes% minutes, do you want to abort? (yes/no): "
if %continue% equ yes (
echo Aborting...
shutdown.exe /a
if errorlevel 1 (
echo ERROR: Could not stop shutdown, try again & echo.
goto abort
)
timeout.exe /t 5 /NOBREAK
endlocal
exit /b
) else (
timeout.exe /t 10 /NOBREAK
endlocal
exit /b
)