0

Whenever i run the .bat file it all goes well i choose my time it says it in minutes and all until it comes to confirming your decision and i really have no clue how to fix it for some reason it just goes to :shutdown

Intention: I am using this as a simple little tool when installing games for example if i have to leave steam to download and install a large game overnight i just choose a time and leave it :)

Note: I have no experience with coding ( except changing values on LUA scripts in games ) so an explanation would be Greatly Appreciated and yes sure i can just use the shutdown command but i wanted to create something a little more fancy

Also if someone could explain to me what the /s in shutdown and /a in set timedelay commands do because as i stated i have little to no experience

.

If you can't answer or can't be bothered thank you for your time either way!

Thank you in advance! :) .

@echo off
cls
title Delayed Shutdown
echo Delayed Shutdown by Martin Angelov
echo Press Any Key To Choose Delay
Pause>NUL

:choosedelay
cls
echo Type in the desired ammount of delay
set /p timedelaysec=
set /a timedelaymin=%timedelaysec% / 60

:confirmation
echo Your current desired shutdown time is:
echo %timedelaysec% Seconds
echo ( %timedelaymin% Minutes )
echo Press 1 to Confirm Shutdown
echo Press 2 to Change Delay
echo press 3 to Exit Program
set /p confirmaation =
if "%confirmaation%" == "1" goto shutdown
if "%confirmaation%" == "2" goto choosedelay
if "%confirmaation%" == "3" goto exit


:shutdown
cls
echo Shutting Down!
echo Delay Chosen:
echo %timedelaysec% Seconds
echo ( %timedelaymin% Minutes )
pause
exit

:exit
cls
echo Exiting Program...
ping 0.0.0.0 -n 2
exit

:Temporary so it doesn't actually enable the shutdown
shutdown /s /t %timedelaysec%
Mee
  • 207
  • 5
  • 11

1 Answers1

1

In batch files, it's usually something simple and frustrating.

Try

set /p confirmaation=

(Note that I removed a space before the equals.)

If that fixes your problems, your environment variable wasn't set to any of the three values you checked for and the logic very naturally went line-by-line to :shutdown.

Good luck!

BaldEagle
  • 918
  • 10
  • 18
  • Come to think of it: In *programming*, it's usually something simple and frustrating! – BaldEagle Jan 31 '16 at 04:22
  • Yep. Just finished testing his program out and looked at http://stackoverflow.com/questions/17524332/get-user-input-in-command-prompt. Ya beat me to the answer! :-) Marked you up one! :-) (No pun intended) – Mark Manning Jan 31 '16 at 04:23
  • Thank you very much kind sir! PS: Just now i realise i spelt confirmation wrong on top of all of it – Martin Angelov Jan 31 '16 at 04:26
  • Maybe I only deserve half a check; you asked some additional questions I didn't address. In general, the former DOS commands (like `shutdown`) still have their documentation at the command prompt. In the case of `shutdown`, type `shutdown /?`. That /s means you want a full power-off (not hibernate, sleep, or others). In `set` (`set /?`), the /a means you want to enter a math string to compute a value. An Internet search will give you lots of examples. – BaldEagle Jan 31 '16 at 04:39
  • Well you just earned it after typing shutdown /? that gives me plenty of ideas to expand the code thank you again for the help! – Martin Angelov Jan 31 '16 at 04:55