If statement problem
Posted: 13 Jan 2009 01:34
I just figured out that it's some strange with this...
This works as long you don't use spaces or like semicolon etc in the variable. Then the batch crash and I don't know why...
What I'm doing wrong? It feel like I have done this before and got it working...
EDIT: Oh, is screws up when it trying to compare if the variable contains multiple words. Puting " " around the %connect% simply solved the problem, because the connect variable may sometimes contain multiple words depending on what the user put into it. Got to always keep that then... Nervermind.
This works as long you don't use spaces or like semicolon etc in the variable. Then the batch crash and I don't know why...
Code: Select all
@echo off
Set /p connect=Users IP Address/computername:
IF /i %connect%==end (
GOTO END
) ELSE (
echo %connect%
pause
GOTO VERYEND
)
:END
pause
:VERYEND
What I'm doing wrong? It feel like I have done this before and got it working...
EDIT: Oh, is screws up when it trying to compare if the variable contains multiple words. Puting " " around the %connect% simply solved the problem, because the connect variable may sometimes contain multiple words depending on what the user put into it. Got to always keep that then... Nervermind.
Code: Select all
@echo off
Set /p connect=Type anything:
IF /i "%connect%"==end (
GOTO END
) ELSE (
echo %connect%
pause
GOTO VERYEND
)
:END
pause
:VERYEND