Search code examples
flashbatch-fileversion

Script to check Flash version isn't really checking version


I need some help making the following work. It's worked before (with other software), but in the case of Flash, it isn't. What I'm trying to accomplish is checking the installed version of Flash. If the installed version of Flash isn't what I want, I want the script to uninstall the current version and install my desired version.

:: Check Flash version and install if not matching.

:: Set version to check for.

SET latestVersion=11.5.502.135
SET key="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Adobe  Flash Player Plugin"

for /f "tokens=3 delims=    " %%G in ('reg query %key% /v DisplayVersion ^| findstr /i current') do (
echo %%G
if %%G EQU %latestVersion% goto END
if %%G NEQ %latestVersion% goto Install
)

:INSTALL
:: Kill IE & FF
taskkill /f /im iexplore.exe /im firefox.exe

::Uninstall Flash
\\path-to-server\Flash-FF-11.8.800.94.exe -uninstall

:: Install Flash for Firefox
\\path-to-server\Flash-FF-11.5.502.135.exe -install

:: Install Flash for IE
\\path-to-server\Flash-IE-11.5.502.135.exe -install

:: Kill Flash updating
COPY /y \\path-to-server\mms.cfg C:\WINDOWS\System32\Macromed\Flash\mms.cfg

:END

The problem is that it's not reading the version that's installed. Instead of echoing something like 11.5.502.135, it's echoing "%G". And since %G does not equal my desired version (11.5.502.135) it's installing every time.

So narrowing it down, the following is my problem:

for /f "tokens=3 delims=    " %%G in ('reg query %key% /v DisplayVersion ^| findstr /i current') do (
echo %%G
if %%G EQU %latestVersion% goto END
if %%G NEQ %latestVersion% goto Install
)

When typing it out manually, as long as I stop at "DisplayVersion" I get the info I'm looking for. But once I proceed to the last part of what's inside the (), that's when I get the errors.


Solution

  • for /f "tokens=2*" %%a in ('reg query "HKEY_CURRENT_USER\Software\Macromedia\FlashPlayerUpdate" /v version') DO SET "FlashVersion=%%b"
    echo %FlashVersion%