Try this:
::It's better to comment out @echo off, and only when the .bat works fine and then use it.
::@echo off
cls
set /p a="the computer will shut in:"
::You'll need to put %a% inside quotes too, otherwise it can't be equal when you input a.
if "%a%"=="a" call :cancel & goto :eof
:: equals to set /a a=a*60, and with /a you don't need %
set /a a*=60
:: You forgot the parameter. And the goto :eof is necessary
call :shut %a%
pause && goto :eof
::You need to put functions at last.
:cancel
shutdown /a
goto :eof
:shut
set a=%1
shutdown -s -f -t %a%
The main problem in your code is the execution flow.
When there's no switch or goto
s, it will execute commands from first line to the last line.
(That's why it asked you infinite times, because every time you call :cancel
, it will execute from :cancel
function to the set /p
again.)
You need to put functions below the main codes.
And in the functions, you need to add goto :eof
(except the last line since it's alreay end of file).
And after the function calls you need add goto :eof
too.