Hello I am fairly new to bach and I was wondering how I could make some code that checks if what you entered in a variable exists before trying it. So I made some code like this:
set /p "command=C:\>"
if "%command%"=="%command:start=%" (
) ELSE (
if "%command%"=="%command:goto=%" (
echo Command not recognized...
) ELSE (
It checks if the entered variable contains "goto" or "start", if yes it starts an entered program (Ex. start iexplore) or it goes to a section of my code (Ex. goto START). The problem is, if you enter a program that does not exist, or if you want to go to a section of code that doesnt exists, it just closes my batch file... How could I make that it checks if that section or program exists before going to :GOTO and if it doesnt exists I want it to go to a section ":GOTONOT". Any help would be very appreciated!