What is the most reliable way to check for firefox

2019-06-22 18:01发布

I am making a software that comes bundled with a firefox extension. In my instalation script I want to prompt a user weather he wants to install the extension. But for that I need:

  1. A way to tell if firefox is installed or not
  2. A way to tell which version of firefox is installed

How would I do these two things in InnoSetup or C#? I tried manually checking the path to default firefox install dir or checking for uninstall records in registry. I think that these methods are not reliable at all.

3条回答
乱世女痞
2楼-- · 2019-06-22 18:11

Here is a shortened list of created keys (by Firefox 27.0.1 installation)

HKLM\SOFTWARE\Classes\FirefoxHTML\
HKLM\SOFTWARE\Classes\FirefoxURL\
HKLM\SOFTWARE\Clients\StartMenuInternet\FIREFOX.EXE\
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe\
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe\Path
HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Mozilla Firefox 27.0.1 (x86 en-US)\
HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe\
HKLM\SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox\27.0.1 (en-US)\
HKLM\SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox 27.0.1\
HKLM\SOFTWARE\Wow6432Node\Clients\StartMenuInternet\FIREFOX.EXE\

One of our client did not have the "Uninstall" one so we'll use another from that list. I am going to use: "firefox is installed when at least one of the following keys exists:"

HKLM\SOFTWARE\Mozilla\Mozilla Firefox\
HKLM\SOFTWARE\Clients\StartMenuInternet\FIREFOX.EXE\
HKLM\SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox\
HKLM\SOFTWARE\Wow6432Node\Clients\StartMenuInternet\FIREFOX.EXE\
查看更多
别忘想泡老子
3楼-- · 2019-06-22 18:17

I think HKLM\SOFTWARE\Clients\StartMenuInternet\FIREFOX.EXE key isn't dependent from OS bits, so I suggest this.

查看更多
时光不老,我们不散
4楼-- · 2019-06-22 18:27

The recommended way is checking whether HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox registry key exists. There will be a subkey for each installed version. If you are paranoid, you can also check the value HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox\<version>\Main\PathToExe - if that file exists then Firefox is really installed and you aren't looking at a stale registry key.

Note that you can only detect a Firefox installation only if the installer was actually used. You can always "install" Firefox manually, simply by unpacking the setup executable with 7zip - into any directory. Nightly builds are also available as regular zip files that are easier to unpack. This will work just fine but won't add any registry keys that will allow you to find this installation.

查看更多
登录 后发表回答