vendredi 4 novembre 2016

Batch file - if not exist not working

I have a problem whereby I am trying to determine if given directory exists on file system before attempting to download a file.

Extract from batch file:

: Create Apache Directory if does not exist
if not exist "%HOMEDRIVE%\Apache" mkdir %HOMEDRIVE%\Apache

:: Setup Apache Ant if Ant does not exist
if not exist "%HOMEDRIVE%\Apache\apache-ant-1.9.7\" (
    SET "FILENAME=%~dp0\apache-ant-1.9.7-bin.zip"
    bitsadmin.exe /transfer "Apache Ant Download" http://ift.tt/2evci1J "%FILENAME%"

    ...further setups here
)

the directory C:/Apache/apache-ant-1.9.7 DOES exist so the code should fail but when run it still downloads the file and tries to do further setups there. Any idea whats wrong and why the if statement is executed where it should not be ?

Thanks

Aucun commentaire:

Enregistrer un commentaire