jeudi 29 septembre 2016

Batch file with if exist statement not working

I have a small network with 3 groups of workstations. I use a batch file to push 3rd party updates by group (workstation names in text files by group) that I'm trying to recycle for this. I want to install an application, but only if Outlook 2016 is installed. Reading the help file for "if", I thought I could just add an "if exist 'filename' goto end", but it's not working. It seems to completely skip the "if exist" line and install the app with or without Outlook 2016. What am I missing?

@ECHO OFF
SET /P GroupName=
FOR /F %%A IN (\\server\share\admin\workingfolder\update\groups\%groupname%.txt) DO (
IF EXIST "\\%%A\c$\program files (x86)\Microsoft Office\Office16\Outlook.exe" GOTO END
xcopy /e /q "\\server\share\admin\software\application" "\\%%A\c$\temp\application\"
psexec cmd "\\%%A\temp\application\application.msi"
rmdir /s /q "\\%%A\c$\temp\application\"
)
exit
:END    
ECHO "Outlook 2016 was not detected, application not installed > "\\server\share\admin\software\application\install logs\%%a.txt" 
exit

Aucun commentaire:

Enregistrer un commentaire