BASH   131
title Conditional Shutdown
Guest on 6th December 2024 12:09:40 AM


  1. @echo off
  2. color 0A
  3. title Conditional Shutdown.
  4.  
  5. :MAIN
  6. cls
  7. ECHO.
  8. ECHO ...............................................
  9. ECHO PRESS 1, 2 OR 3 to select your task, or 4 to EXIT.
  10. ECHO ...............................................
  11. ECHO.
  12. ECHO 1 - Open Notepad
  13. ECHO 2 - Open Calculator
  14. ECHO 3 - Open Notepad AND Calculator
  15. ECHO 4 - EXIT
  16. ECHO.
  17. ECHO.0 GOTO NEXT MENU
  18. echo.
  19.  
  20. SET /P M=Type 1, 2, 3, 4 or 0 then press ENTER :
  21. IF %M%==1 GOTO NOTE
  22. IF %M%==2 GOTO CALC
  23. IF %M%==3 GOTO BOTH
  24. IF %M%==4 GOTO EOF
  25. IF %M%==0 GOTO start
  26.  
  27.  
  28. :NOTE
  29. cd %windir%\system32\notepad.exe
  30. start notepad.exe
  31. GOTO MAIN
  32.  
  33. :CALC
  34. cd %windir%\system32\calc.exe
  35. start calc.exe
  36. GOTO MAIN
  37.  
  38. :BOTH
  39. cd %windir%\system32\notepad.exe
  40. start notepad.exe
  41. cd %windir%\system32\calc.exe
  42. start calc.exe
  43. GOTO MAIN
  44.  
  45.  
  46.  
  47. :start
  48. cls
  49. echo Welcome, %USERNAME%
  50. echo What would you like to do?
  51. echo.
  52. echo 1. Shutdown in specified time
  53. echo 2. Shutdown at a specified time
  54. echo 3. Shutdown now
  55. echo 4. Restart now
  56. echo 5. Log off now
  57. echo 6. Hibernate now
  58. echo.
  59. echo 0. Quit
  60. echo.
  61. echo 9 GOTO MAIN MENU
  62.  
  63. set /p choice="Enter your choice: "
  64. if "%choice%"=="1" goto shutdown
  65. if "%choice%"=="2" goto shutdown-clock
  66. if "%choice%"=="3" shutdown.exe -s -f
  67. if "%choice%"=="4" shutdown.exe -r -f
  68. if "%choice%"=="5" shutdown.exe -l -f
  69. if "%choice%"=="6" shutdown.exe -h -f
  70. if "%choice%"=="0" exit
  71. if "%choice%"=="9" goto MAIN
  72.  
  73.  
  74.  
  75. echo Invalid choice: %choice%
  76. echo.
  77. pause
  78. cls
  79. goto start
  80.  
  81. :shutdown
  82. cls
  83. set /p min="Minutes until shutdown: "
  84. set /a sec=60*%min%
  85. shutdown.exe -s -f -t %sec%
  86. echo Shutdown initiated at %time%
  87. echo.
  88. goto cancel
  89.  
  90. :shutdown-clock
  91. echo.
  92. echo the time format is HH:MM:SS (24 hour time)
  93. echo example: 14:30:00 for 2:30 PM
  94. echo.
  95. set /p tmg=enter the time that you wish the computer to shutdown on:
  96. schtasks.exe /create /sc ONCE /tn shutdown /st %tmg% /tr "shutdown.exe -s -t 00"
  97. echo shutdown initiated at %tmg%
  98. echo.
  99.  
  100. :cancel
  101. set /p cancel="Type cancel to stop shutdown: "
  102. if not "%cancel%"=="cancel" exit
  103. shutdown.exe -a
  104. cls
  105. schtasks.exe /end /tn shutdown
  106. cls
  107. schtasks.exe /delete /tn shutdown
  108. cls
  109. echo Shutdown is cancelled.
  110. echo.
  111. pause
  112. exit

Raw Paste

Login or Register to edit or fork this paste. It's free.