Variable space

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
sebb
Posts: 5
Joined: 20 Apr 2012 17:14

Variable space

#1 Post by sebb » 20 Apr 2012 17:19

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???

Fawers
Posts: 187
Joined: 08 Apr 2012 17:11
Contact:

Re: Variable space

#2 Post by Fawers » 20 Apr 2012 17:24

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.
Last edited by Fawers on 20 Apr 2012 17:28, edited 1 time in total.

sebb
Posts: 5
Joined: 20 Apr 2012 17:14

Re: Variable space

#3 Post by sebb » 20 Apr 2012 17:27

Thanks! XD

Post Reply