@echo off
:: vamos criar as variaveis
set finalhour=
set finalmins=
set shutd=
if [%1]==[] goto usage
set hour=%1
set mins=%2
if [%hour%]==[0] (goto skip)
set /a finalhour=3600*%hour%
cls
:skip
if [%mins%]==[0] (goto fail)
:nofail
set /a finalmins=60*%mins%
set /a shutd=%finalhour%+%finalmins%
cls
goto sucess
:usage
echo.
echo. Parametro incorreto
echo. Use autoshutdown com os parametros:
echo. x (onde x = houras)
echo. y (onde y = minutos)
echo. Exemplo:
echo. autoshutdown 1 40
echo. Calcularia e desligaria o computador em 1 hora e 40 minutos
echo.
exit /b 1
:fail
if [%hour%]==[0] (
echo.
echo. Operation faied
echo. You must enter at least an hour or a minute
echo.
exit /b 1
) else (
goto nofail
)
:sucess
echo %shutd% > autoshutdown.log
for /f "delims=1234567890 " %%s in (autoshutdown.log) do set pvtc=%%s
if [%pvtc%]==[-] goto unsmart
echo.
echo. Desligando a ***** do pc...
echo %shutd% > lawl.txt
for /f "delims=" %%s in (lawl.txt) do set stdhn=%%s
del lawl.txt
del autoshutdown.log
shutdown -s -t %stdhn%
exit /b 1
:unsmart
echo.
echo. You cannot use negative numbers
echo. Try next time.
echo.
del autoshutdown.log
set /p fail=
taskkill /f /im cmd.exe
exit /b 1