This site is a wealth of information, and I've found some great solutions, but they're all parts (out of order) for my need. Adobe has recently issued a security fix for Acrobat, unfortunately it's a minor patch, and also requires the previous patch version. Detail - In order to update to Acrobat 11.0.08, you must have 11.0.07 installed. Some machines have 11.0.06 and below. Luckily, 11.0.07 has no prerequisites other than the major version of 11 be installed.
What I need to do is check if the machine has 11.0.07 or 11.0.08. If it does not have either 7 or 8, that 7 be installed, then 8. If 7 is already installed, then have 8 install. If 8 is already installed, do nothing. Upgrade files are on a share and require admin privileges to install, so it'll be manually run per machine requiring the update.
I hatched the following together -
#@echo off
SETLOCAL
cls
rem Installing an update which results in Adobe Reader 11.0.08
echo.
echo.
echo Installing Acrobat Reader 11.0.07 update... please wait...
rem if exist "\\server\share\Logs\%computername%_acrobat_reader_11008.txt" goto gotit
rem Find generates an errorlevel of zero if it encounters a match.
Reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /s ^| find "DisplayName" ^| find "Adobe Acrobat XI Pro" ^| find "DisplayVersion" ^| find "11.0.07"
if %errorlevel% EQU 1 (
goto got7
) ELSE (
goto wrongversion
)
:got7
echo Installing 11.0.08 Update
Reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /s ^| find "DisplayName" ^| find "Adobe Acrobat XI Pro" ^| find "DisplayVersion" ^| find "11.0.08"
if %errorlevel% EQU 0 (
goto gotit
) ELSE (
net use q: "\\server\share\Source\patches" /persistent:no
q:
msiexec /quiet /update Q:\AcrobatSecUpd11008.msp > "\\server\share\Logs\%computername%_acrobat_reader_11008.txt"
goto gotit
)
:wrongversion
Reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /s ^|find "DisplayName" ^| find "Adobe Acrobat XI Pro" ^| find "DisplayVersion" ^| find "11.0.08"
if %errorlevel% EQU 0 (
goto gotit
) ELSE (
echo Installing 11.0.07 Update
net use q: "\\server\shareSource\patches" /persistent:no
q:
msiexec /quiet /update Q:\AcrobatUpd11007.msp > "\\server\share\Logs\%computername%_acrobat_reader_11008.txt"
goto got7
)
:gotit
pause
Unfortunately, the registry strings values are separated. DisplayName only shows "Adobe Acrobat XI Pro", hence the multiple "find" requests.
your if %errorlevel% EQU 1 (
directly contradicts your rem about finds return. i think you mean equ 0 here.
but you should not use this construct anyway, better to use if errorlevel 1
which tests for 1 or higher.
also, if you filter for the displayname, your next filter can't very well find the version number from these results.
something along these lines should work:
@ECHO off
SETLOCAL enabledelayedexpansion
for /F "usebackq tokens=*" %%a in (`Reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /s /f "Adobe Acrobat XI Pro"`) do (
SET KEY=%%a
GOTO :next
)
:next
IF NOT "%KEY%" EQU "" (
FOR /F "usebackq tokens=1,3" %%a in (`Reg query %KEY% /f DisplayVersion`) do (
IF "%%a" EQU "DisplayVersion" SET VER=%%b
)
IF "!VER!" EQU "11.0.07" ECHO found
)