Windows : Only Run Install Startup Script if Directory Doesn’t Exist

active-directorystartup-scriptswindows-server-2008-r2

I want to install some programs via a startup script, but once it has run for the first time it'll just reinstall wasting time and overwriting. It's a Server 2008 R2.

Somewhere I found this

IF NOT "C:\Program Files\Microsoft Security Client"=="" 
(
    echo "Already Installed"
) 
else 
(
    "\\192.168.1.104\Programs\Microsoft Security Essentials\Microsoft Security Essentials.exe" /s /runwgacheck
)

IF NOT "C:\Program Files (x86)\Adobe\Reader 10.0"=="" 
(
    echo "Already Installed"
) 
else 
(
    "\\192.168.1.104\Programs\Adobe Reader\AdbeRdr1012_en_US.exe" /sAll /rs /msi EULA_ACCEPT=YES
)

But it doesn't work. How could I get it to?

Best Answer

You need IF EXIST instead of just IF for batch programming.

e.g.

IF NOT EXIST "C:\Program Files\Microsoft Security Client" (
  :: Install product
)
Related Topic