S
Slickuser
When I execute this batch script with two prompts set to N.
What am I doing wrong that it's entering the second "if statement"?
Result:
Enter (Y/N) N
Enter2 (Y/N) N
Msg 1
C_PATH exist
Should not be here!
@SET OVERWRITE=N
@SET /P OVERWRITE="Enter (Y/N) "
@SET C_PATH=C:\Windows
:: BEGIN
@IF "%OVERWRITE%" == "Y" (
@ECHO Hey %USERNAME%
@ECHO Got IN overwrite
@IF EXIST %C_PATH% (
@ECHO %C_PATH% exist
)
@IF "A" == "A" (
@ECHO Hello!!
)
@ECHO Should not display this message!
)
@SET COMPILE=N
@SET C_OVERWRITE=N
@SET /P COMPILE="Enter2 (Y/N) "
@IF "%COMPILE%" == "Y" (
@ECHO Hey2 %USERNAME%
:: Check if directory is already exist
@IF EXIST %C_PATH% (
@ECHO %C_PATH% exist
@SET /P C_OVERWRITE="Overwrite %C_PATH% [Y/N] "
)
:: Ask for overwrite
@IF "%C_OVERWRITE%" == "Y" (
@ECHO C overwrite
)
@ECHO Msg 1
@IF EXIST %C_PATH% (
@ECHO C_PATH exist
)
@ECHO Should not be here!
)
What am I doing wrong that it's entering the second "if statement"?
Result:
Enter (Y/N) N
Enter2 (Y/N) N
Msg 1
C_PATH exist
Should not be here!
@SET OVERWRITE=N
@SET /P OVERWRITE="Enter (Y/N) "
@SET C_PATH=C:\Windows
:: BEGIN
@IF "%OVERWRITE%" == "Y" (
@ECHO Hey %USERNAME%
@ECHO Got IN overwrite
@IF EXIST %C_PATH% (
@ECHO %C_PATH% exist
)
@IF "A" == "A" (
@ECHO Hello!!
)
@ECHO Should not display this message!
)
@SET COMPILE=N
@SET C_OVERWRITE=N
@SET /P COMPILE="Enter2 (Y/N) "
@IF "%COMPILE%" == "Y" (
@ECHO Hey2 %USERNAME%
:: Check if directory is already exist
@IF EXIST %C_PATH% (
@ECHO %C_PATH% exist
@SET /P C_OVERWRITE="Overwrite %C_PATH% [Y/N] "
)
:: Ask for overwrite
@IF "%C_OVERWRITE%" == "Y" (
@ECHO C overwrite
)
@ECHO Msg 1
@IF EXIST %C_PATH% (
@ECHO C_PATH exist
)
@ECHO Should not be here!
)