Skip to content

Instantly share code, notes, and snippets.

@bozhink
Created August 27, 2015 19:26
Show Gist options
  • Save bozhink/fc7c21ef5f832f1eb314 to your computer and use it in GitHub Desktop.
Save bozhink/fc7c21ef5f832f1eb314 to your computer and use it in GitHub Desktop.
@echo off
color 0A
title Conditional Shutdown
:start
echo What would you like to do?
echo.
echo 1. Shutdown in specified time
echo 2. Shutdown now
echo 3. Restart now
echo 4. Log off now
echo 5. Hibernate now
echo.
echo 0. Quit
echo.
set /p choice="Enter your choice: "
if %choice%==1 goto shutdown
if %choice%==2 shutdown -s -f
if %choice%==3 shutdown -r -f
if %choice%==4 shutdown -l -f
if %choice%==5 shutdown -h -f
if %choice%==0 exit
echo Invalid choice: %choice%
echo.
pause
cls
goto start
:shutdown
cls
set /p sec="Minutes until shutdown: "
set /a min=60*%sec%
shutdown -s -f -t %min%
echo Shutdown initiated at %time%
echo.
set /p cancel="Type cancel to stop shutdown "
if %cancel%==cancel shutdown -a
if %cancel%==cancel cls
if %cancel%==cancel echo Shutdown is cancelled.
if %cancel%==cancel echo.
if %cancel%==cancel pause
if %cancel%==cancel exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment