Thanks Mark
However, with the new IF DEFINED loop, I find it the batch script behave
differently. For example, in the code snippet below, if I detected env
variable asm_main_location is set, I will call another batch file to set
some env varible then use the env varible to create a folder.
With the IF DEFINED loop, for some reason the %ASMFULL% env variable dont
get recognise and hence no folder is created, but at the end of the batch
script I can clear see that %ASMFULL% is set via SET ASMFULL.
And if I comment out the IF DEFINED loop, then the batch script will go
ahead and create a new folder based on the ASMFULL value.
any ideas what may have been wrong with my script?
set asm_main_location=blah
echo [Setting 3rd Party Environment]
if DEFINED asm_main_location (
call R:\build\versions.bat /o
if not exist %_INV_3RD_PARTY_LOCALDIR%\ASM\%ASMFULL% (
mkdir %_INV_3RD_PARTY_LOCALDIR%\ASM\%ASMFULL%
) else (
echo Folder %_INV_3RD_PARTY_LOCALDIR%\ASM\%ASMFULL% existed already
)
)
echo [Finish Setting Environment]
Mark V said:
IF /?
"The DEFINED conditional works just like EXISTS except it takes an
environment variable name and returns true if the environment
variable is defined." (W2K)