Reputation: 3
I need help with my if command in my file converter. I keep changing the command a bit, but it just returns with
(exit) was unexpected at this time.
And then it closes command prompt. The if command is:
if %success% == 0 (exit) else (goto converter)
Please help.
Upvotes: 0
Views: 1504
Reputation: 89
Instead of using goto use call and write exit after the if - else condition
set /A success=1
if %success%==0 ( exit ) else ( call :converter )
exit
:converter
echo In Conveter Function
pause
At the end of If-Else you must write exit otherwise converter function will be called twice
Upvotes: 0
Reputation: 79982
In all probability, success
is not assigned, ie. set to nothing
if "%success%"=="0" (exit) else (goto converter)
should succeed - but remember exit
will terminate the cmd
session...
Upvotes: 2