As the title suggest, how exactly would you do two different action (like below) depending on the value of a variable in a Batch file.
E.g.
IF %NUMBER% = 2 do ECHO Number 2
IF %NUMBER% = 1 do ECH开发者_StackOverflow社区O Number 1
Here are two examples
IF "%COMPUTERNAME%" == "Bastie" GOTO :TRUE
REM Insert Code for false
GOTO NEXT
:TRUE
REM Insert Code for true
echo Willkommen Zuhause
REM Jetzt wird der if Zweig verlassen
GOTO NEXT
:NEXT
echo.Have a nice Day!
Beispiel
IF "%COMPUTERNAME%" == "Bastie" ( echo Willkommen zu Hause! ) ELSE ( echo Du bist auf Computer: %COMPUTERNAME% )
Microsoft has encountered this before. Basically, to fit your scenario:
if %NUMBER% EQU 1 goto number1
if %NUMBER% EQU 2 goto number2
:number1
echo Number 1
:number2
echo Number 2
精彩评论