Silently Updating Firefox via Command Prompt (Windows)

白昼怎懂夜的黑 提交于 2019-11-28 11:46:06

I suggest for this task the following commented batch code:

@echo off
set "FirefoxFolder="
set "FirefoxVersion=37"

rem Get path of installed Firefox directly from Windows registry.
for /F "skip=2 tokens=1,2*" %%A in ('%SystemRoot%\System32\reg.exe query "HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe" /v Path 2^>nul') do (
    if /I "%%A" == "Path" (
        set "FirefoxFolder=%%C"
        if defined FirefoxFolder goto CheckFirefox
    )
)

:InstallFirefox
echo Installing Firefox ...

:UpdateFireFox
\\***\***\Firefox-Setup-%FirefoxVersion%.exe -ms
goto :EOF

:CheckFirefox
if not exist "%FirefoxFolder%\firefox.exe" goto InstallFirefox

rem Check if version of Mozilla Firefox starts with defined number.
rem The space at beginning makes sure to find the major version number.
"%FirefoxFolder%\firefox.exe" -v | %SystemRoot%\System32\more | %SystemRoot%\System32\find.exe " %FirefoxVersion%" >nul
if errorlevel 1 (
    echo Updating Firefox to version %FirefoxVersion% ...
    goto UpdateFireFox
)

echo Firefox with version %FirefoxVersion% is already installed.

The path to Firefox executable is read directly from Windows registry. This should work on any Windows, even on Windows XP.

I have read that for updating Firefox just the installer must be executed. The installer automatically detects an already installed version of Firefox and updates it without changing the user settings.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!