Page 1 of 1

Variable space

Posted: 20 Apr 2012 17:19
by sebb
I am making this batch file like this:
:COMMANDPRO
set /p "command=C:\> "
if %command%==net user shutdown goto SHUTDOWN
echo Command not recognised...
goto COMMANDPRO

It doesn't work because I can't have any spaces in the IF statement. For it to work, I would have to type in netussershutdown but I want to type "net user shutdown"! Any ideas how I could make this work WITH spaces in the variable???

Re: Variable space

Posted: 20 Apr 2012 17:24
by Fawers

Code: Select all

if /i "%command%" == "net user shutdown" goto SHUTDOWN

Edit: You might want to use the /i switch. It makes IF statements (and lots of other commands) case insensitive.

Re: Variable space

Posted: 20 Apr 2012 17:27
by sebb
Thanks! XD