[Solved] How to do 2 commands at the same time using batch


With if exist use the variableNAME, not the variable itself (no %)

Your line

if not defined %answer% echo Not an acceptable answer & goto READYTOBEGIN?

is parsed (because %answer% is empty) as:

if not defined echo Not an acceptable answer & goto READYTOBEGIN?

echo is also not defined (probably), so the command to be executed is Not – which leads to an error “command not found”.
If it is defined, there’s no error, but that’s not much better. Let’s assume, the user entered hello, then the line gets parsed as:

if not defined hello echo Not an acceptable answer & goto READYTOBEGIN?

The variable hello is probably not defined, but it might be – so you have an unpredictable behaviour.

The correct syntax for your line would be:

if not defined answer echo Not an acceptable answer & goto READYTOBEGIN?

What do you do, when the user enters for example qwertzui? answer is defined, so the echo and goto are being ignored. Better omit the last if completeley and replace the line with just:

echo Not an acceptable answer & goto READYTOBEGIN?

so it fires, if answer is either not defined or didn’t get catched with the previous ifs

solved How to do 2 commands at the same time using batch