MineCake PvP
MineCake PvP

Reputation: 69

Batch File Crashes From Goto Command

I was making my own little batch file.

It will say Bad Command then goto the typing prompt again but everything I type the wrong command (if) I made cmd my batch shuts off

Code:

:ccc
set /p cmd=C:\
if %cmd%==edit goto edit
if %cmd%==Edit goto edit
if %cmd%==exit goto exit
if %cmd%==Exit goto exit
if %cmd%==Restart goto restart
if %cnd%==restart goto restart
echo Bad Command
goto ccc    

Upvotes: 2

Views: 559

Answers (1)

Hackoo
Hackoo

Reputation: 18837

You should adding quotes and take a look at this : If /I case Insensitive string comparison

@echo off
:ccc
set /p "cmd=C:\ "
if /I "%cmd%"=="edit" goto edit
if /I "%cmd%"=="exit" goto exit
if /I "%cmd%"=="restart" goto restart
echo Bad Command
goto ccc    

Upvotes: 2

Related Questions