检查 Firefox 安装的最可靠方法是什么?
我正在制作一个与 Firefox 扩展捆绑在一起的软件。在我的安装脚本中,我想提示用户是否想要安装扩展。但为此我需要:
- 一种方法来判断是否安装了 Firefox
- 一种方法来判断安装了哪个版本的 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:
- A way to tell if firefox is installed or not
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
推荐的方法是检查
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 valueHKEY_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.
这是创建的密钥的简短列表(通过 Firefox 27.0.1 安装)
我们的一个客户端没有“卸载”密钥,因此我们将使用该列表中的另一个密钥。
我将使用:“当至少存在以下键之一时,将安装 Firefox:”
Here is a shortened list of created keys (by Firefox 27.0.1 installation)
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\Clients\StartMenuInternet\FIREFOX.EXE 键不依赖于操作系统位,所以我建议这样做。
I think
HKLM\SOFTWARE\Clients\StartMenuInternet\FIREFOX.EXE
key isn't dependent from OS bits, so I suggest this.