I have a batch file and when I execute it, it got different variable. I don't know where I fail. It has two choices, first selecting on what game then set it to variable game
then another choice to select what PC then it uses go to
command. but the result is different. This is my code:
@ECHO OFF
CLS
ECHO Copy Game Files From Choices Below
ECHO 1.Crossfire
ECHO 2.Dota2
ECHO 3.Dragon Nest
ECHO 4.Fortnite
ECHO 5.Rules Of Survival
ECHO 6.World Of Tantra
ECHO.
CHOICE /C 123456 /M "Enter your choice: "
:: Note - list ERRORLEVELS in decreasing order
IF ERRORLEVEL 6 Set Game=WorldOfTantra
IF ERRORLEVEL 5 Set Game=RulesOfSurvival
IF ERRORLEVEL 4 Set Game=Fortnite
IF ERRORLEVEL 3 Set Game=DragonNest
IF ERRORLEVEL 2 Set Game=Dota2
IF ERRORLEVEL 1 Set Game=Crossfire
::=====================================
ECHO Select PC to Copy Files
ECHO 1.PC1
ECHO 2.PC2
ECHO 3.PC3
ECHO 4.PC4
ECHO.
CHOICE /C 1234 /M "Enter your choice: "
:: Note - list ERRORLEVELS in decreasing order
IF ERRORLEVEL 4 SET PCCode=JeraldPunx04 GOTO CopyFiles
IF ERRORLEVEL 3 SET PCCode=JeraldPunx03 GOTO CopyFiles
IF ERRORLEVEL 2 SET PCCode=JeraldPunx02 GOTO CopyFiles
IF ERRORLEVEL 1 SET PCCode=JeraldPunx01 GOTO CopyFiles
::=====================================
:CopyFiles
echo "Test Variable: %Game% in %PCCode%"
if %Game%==WorldOfTantra (
echo "Copying %Game% in %PCCode%"
)
if %Game%==RulesOfSurvival (
echo "Copying %Game% in %PCCode%"
)
if %Game%==Fortnite (
echo "Copying %Game% in %PCCode%"
)
if %Game%==DragonNest (
echo "Copying %Game% in %PCCode%"
)
if %Game%==Dota2 (
echo "Copying %Game% in %PCCode%"
)
if %Game%==Crossfire (
echo "Copying %Game% in %PCCode%"
)
GOTO End
::=====================================
:End
pause
It's just a simple but yet I'm having hard time to trace this.