Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Adding windows calculator

DivaythFyrDivaythFyr Posts: 1Member
I'm trying to figure out how to add a calculator to this batch program someone else has made. However whenever I try to run the calculator it brings me to the shutdown menu. I'm fairly sure I'm missing something, I do not know what.

[code]@ECHO OFF
title none
set /a hour="0"
set /a min="0"
set /a sec="0"
:color FC
echo %date%
echo.
pause
:choose
cls
echo Shutdown computer = S
echo Restart computer = R
echo Logoff computer = L
echo Calculator = C
echo Exit this program = E
echo.
set /p choose="Hello, %username%, what would you like to do?: "
if %choose%==s goto begin
if %choose%==S goto begin
if %choose%==r goto begin
if %choose%==R goto begin
if %choose%==l goto begin
if %choose%==L goto begin
if %choose%==C goto begin
if %choose%==c goto begin
if %choose%==e goto exit
if %choose%==E (goto exit) else goto erchoose
:begin
cls
echo Right now = 1
echo In 5 seconds = 2
echo In 30 seconds = 3
echo In 1 minute = 4
echo In 5 minutes = 5
echo In 15 minutes = 6
echo In 30 minutes = 7
echo In 1 hour = 8
echo In 2 hours = 9
echo Specified time = 0
echo.
set /p userinp="What time would you like to shutdown? (0-9): "
if %userinp%==1 goto shutdown
if %userinp%==2 goto 5sec
if %userinp%==3 goto 30sec
if %userinp%==4 goto 1min
if %userinp%==5 goto 5min
if %userinp%==6 goto 15min
if %userinp%==7 goto 30min
if %userinp%==8 goto 1hr
if %userinp%==9 goto 2hr
if %userinp%==0 (goto specify) else goto erbegin
:yay
if %choose%==s goto shutdown
if %choose%==S goto shutdown
if %choose%==r goto restart
if %choose%==R goto restart
if %choose%==l goto logoff
if %choose%==L goto logoff
if %choose%==C run %windir%system32calc.exe
if %choose%==c run %windir%system32calc.exe
:shutdown
cls
@ECHO
shutdown -s
goto exit
:restart
cls
@ECHO
shutdown -r
goto exit
:logoff
cls
@ECHO
shutdown -l
goto exit
:5sec
cls
@ECHO
shutdown -f
goto exit
:5sec
cls
set /p userinp="Is 5 seconds the time you want to wait? (Y/N): "
if %userinp%==Y goto start
if %userinp%==y goto start
if %userinp%==yes goto start
if %userinp%==Yes goto start
if %userinp%==YES (goto start) else goto begin
cls
set /a sec="5"
goto start
:30sec
cls
set /p userinp="Is 30 seconds the time you want to wait? (Y/N): "
if %userinp%==Y goto start
if %userinp%==y goto start
if %userinp%==yes goto start
if %userinp%==Yes goto start
if %userinp%==YES (goto start) else goto begin
cls
set /a sec="30"
goto start
:1min
cls
set /p userinp="Is 1 minute the time you want to wait? (Y/N): "
if %userinp%==Y goto start
if %userinp%==y goto start
if %userinp%==yes goto start
if %userinp%==Yes goto start
if %userinp%==YES (goto start) else goto begin
cls
set /a min="1"
goto start
:5min
cls
set /p userinp="Is 5 minutes the time you want to wait? (Y/N): "
if %userinp%==Y goto start
if %userinp%==y goto start
if %userinp%==yes goto start
if %userinp%==Yes goto start
if %userinp%==YES (goto start) else goto begin
cls
set /a min="5"
goto start
:15min
cls
set /p userinp="Is 15 minutes the time you want to wait? (Y/N): "
if %userinp%==Y goto start
if %userinp%==y goto start
if %userinp%==yes goto start
if %userinp%==Yes goto start
if %userinp%==YES (goto start) else goto begin
cls
set /a min="15"
goto start
:30min
cls
set /p userinp="Is 30 minutes the time you want to wait? (Y/N): "
if %userinp%==Y goto start
if %userinp%==y goto start
if %userinp%==yes goto start
if %userinp%==Yes goto start
if %userinp%==YES (goto start) else goto begin
cls
set /a min="30"
goto start
:1hr
cls
set /p userinp="Is 1 hour the time you want to wait? (Y/N): "
if %userinp%==Y goto start
if %userinp%==y goto start
if %userinp%==yes goto start
if %userinp%==Yes goto start
if %userinp%==YES (goto start) else goto begin
cls
set /a hour="1"
goto start
:2hr
cls
set /p userinp="Is 2 hours the time you want to wait? (Y/N): "
if %userinp%==Y goto start
if %userinp%==y goto start
if %userinp%==yes goto start
if %userinp%==Yes goto start
if %userinp%==YES (goto start) else goto begin
cls
set /a hour="2"
goto start
:specify
cls
set /p hour="How many hours do you want to wait?: "
:min
cls
if %hour% LSS 0 goto errorhour
set /p min="How many minutes do you want to wait?: "
:sec
cls
if %min% GTR 59 (goto errormin)
if %min% LSS 0 goto poop
set /p sec="How many seconds do you want to wait?: "
cls
if %sec% GTR 59 (goto errorsec)
if %sec% LSS 0 goto poopie
goto correction
:correction
set /p userinp="Is %hour% hour(s), %min% minute(s), and %sec% second(s) the time you want to wait? (Y/N): "
if %userinp%==Y goto start
if %userinp%==y goto start
if %userinp%==yes goto start
if %userinp%==Yes goto start
if %userinp%==YES (goto start) else goto begin
:start
cls
echo Your computer will be shutdown in %hour% hour(s)
echo %min% minute(s)
echo and %sec% second(s)...
set /a sec="%sec%-1"
ping -n 2 127.0.0.1 >NUL
if %sec%==-1 set /a min="%min%-1"
if %sec%==-1 set /a sec="59"
if %min%==-1 set /a hour="%hour%-1"
if %min%==-1 set /a min="59"
if %hour%==-1 goto yay
goto start
:errorhour
cls
echo %hour% is less than 0!
ping -n 4 127.0.0.1 >NUL
goto specify
:errormin
cls
echo %min% minutes is bigger than 59! (60 minutes is an hour)
ping -n 5 127.0.0.1 >NUL
goto min
:poop
cls
echo %min% is less than 0!
ping -n 4 127.0.0.1 >NUL
goto min
:errorsec
cls
echo %sec% seconds is bigger than 59! (60 seconds is a minute)
ping -n 5 127.0.0.1 >NUL
goto sec
:exit
cls
exit
:erchoose
cls
echo %choose% isn't a valid option!
ping -n 5 127.0.0.1 >NUL
goto choose
:erbegin
cls
echo %userinp% isn't a valid option!
ping -n 5 127.0.0.1 >NUL
goto begin[/code]

Any help would be great.

Comments

  • pseudocoderpseudocoder Posts: 687Member ✭✭✭
    add a label

    if %choose% == C goto calc
    if %choose% == c goto calc

    :calc
    run %windir%system32calc.exe
    goto calc_end
    :other labels
    ...
    ...
    :calc_end

    try something like that; it looks like it's defaulting to a shutdown because of being included inside of :begin

Sign In or Register to comment.