检查 Firefox 安装的最可靠方法是什么?

发布于 2024-11-30 11:11:07 字数 229 浏览 1 评论 0原文

我正在制作一个与 Firefox 扩展捆绑在一起的软件。在我的安装脚本中,我想提示用户是否想要安装扩展。但为此我需要:

  1. 一种方法来判断是否安装了 Firefox
  2. 一种方法来判断安装了哪个版本的 Firefox

我如何在 InnoSetup 或 C# 中执行这两件事?我尝试手动检查默认 Firefox 安装目录的路径或检查注册表中的卸载记录。我认为这些方法根本不可靠。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

独守阴晴ぅ圆缺 2024-12-07 11:11:07

推荐的方法是检查 HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox 注册表项是否存在。每个安装的版本都会有一个子项。如果您偏执,您还可以检查值 HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox\\Main\PathToExe - 如果该文件存在,则 Firefox 确实已安装,而您并未安装查看过时的注册表项。

请注意,只有实际使用了安装程序,您才能检测到 Firefox 安装。您始终可以手动“安装”Firefox,只需使用 7zip 将安装可执行文件解压到任意目录即可。每晚构建也可以作为更容易解压的常规 zip 文件提供。这将工作得很好,但不会添加任何允许您找到此安装的注册表项。

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.

恰似旧人归 2024-12-07 11:11:07

这是创建的密钥的简短列表(通过 Firefox 27.0.1 安装)

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\

我们的一个客户端没有“卸载”密钥,因此我们将使用该列表中的另一个密钥。
我将使用:“当至少存在以下键之一时,将安装 Firefox:”

HKLM\SOFTWARE\Mozilla\Mozilla Firefox\
HKLM\SOFTWARE\Clients\StartMenuInternet\FIREFOX.EXE\
HKLM\SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox\
HKLM\SOFTWARE\Wow6432Node\Clients\StartMenuInternet\FIREFOX.EXE\

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\
葮薆情 2024-12-07 11:11:07

我认为 HKLM\SOFTWARE\Clients\StartMenuInternet\FIREFOX.EXE 键不依赖于操作系统位,所以我建议这样做。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文