Archive: How to detect if Firefox is installed?


How to detect if Firefox is installed?
Hello, all ...

I need to modify our NSIS installer to install some browser-specific plugins i've written. The IE plugin was easy (since it can live anywhere), but the Firefox plugin needs to be copied to Firefox's plugins directory. What is the bets way to determine if Firefox is really installed? I could easily look for /program files/mozilla firefox, but this seems a rather simplistic check that could fail if the user decides to install Firefox somewhere else. Is there a better way to determine if Firefox is installed on a user's machine?

Regards,

John


query the registry for the firefox location

e.g. via HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Mozilla Firefox


naa, that's totally rubbish...

ReadRegStr $R8 HKLM "SOFTWARE\Mozilla\Mozilla Firefox" "CurrentVersion"
ReadRegStr $R9 HKLM "SOFTWARE\Mozilla\Mozilla Firefox\$R8\Main" "PathToExe"


it's been awhile since you posted, so you've probably already moved on to new and better projects, but for any others facing this same problem:

The correct way to install a plugin is usually *not* to put it in the Firefox Plugins directory. This will more or less work, but it has some limitations:[list=1][*]it requires that firefox is already installed before you install your plugin[*]Only Firefox (and only one copy of firefox) has access to your plugin. (Most browsers use the standard NPAPI/NPRuntime interface for plugins)[*]It requires administrator privileges to install this way.[/list=1]The ideal way to install a plugin is outlined here:
https://developer.mozilla.org/en/Plu...nstall_Problem

Essentially, you just add some registry entries identifying where the plugin is located and your computer will find it. The one downside to this is that Firefox 2 will not find it if it's in HKEY_CURRENT_USER (though Firefox 3, Opera, Chrome, and Safari on windows all will). If you need to install it w/out administrator privileges so that it will work for Firefox 2, try installing it as an extension in the registry:

https://developer.mozilla.org/en/Add...ndows_Registry

If you have access to HKEY_LOCAL_MACHINE, you can install it there and all the browsers should find it fine. This is also much easier to implement in NSIS, since you don't have to search through the registry and hard drive to find where to put the plugin... just stick it in $APPDATA

Hope that helps someone!


>> The correct way

says who? ;)

take the flash plugin as example and analyse it ;)
it does both - adobe knows why

i would say its the better way cause all NP-based browser can find it (if they were build to find it)

answered 1) why to install a plugin when the browser is not there?
for future purpose, nah, not really.

answered 2) idd - the actual plugin folder only belongs to it
of course you have to think of all installed np-based browser
advantage - firefox will find it for 100% - also in case the registry is mixed up
disadvantage - in case of two places firefox get a hickcove

answered 3) i'm not sure about that. its just as simple as copy&paste
but it needs registry access for the machine in your way

here the example for adobe flash player in registry

[HKEY_LOCAL_MACHINE\SOFTWARE\MozillaPlugins\@adobe.com/FlashPlayer]
"Path"="C:\\WINDOWS\\system32\\Macromed\\Flash\\NPSWF32.dll"
"XPTPath"="C:\\WINDOWS\\system32\\Macromed\\Flash\\flashplayer.xpt"
"ProductName"="Adobe® Flash® Player Plugin"
"Vendor"="Adobe Systems Incorporated"
"Description"="Adobe® Flash® Player 10"
"Version"="10.0.12.36"


something to mention - extensions dont need machine access
HKEY_CURRENT_USER\Software\Mozilla\Firefox\Extensions

e.g.
"mozilla_cc@internetdownloadmanager.com"=...

same argument - extension can be installed directly into the profile - or lokal (user only) for all programs

BTW i cant see your links...

Okay, I'll agree with that. "The best way" is certainly a relative, and opinionated, statement. Allow me to rephrase it, then: After a lot of research, study, and drawing on 2 years of history of a browser plugin that has been installed on literally millions of machines, I submit my opinion that this is the easiest, most scalable way to install a plugin. :-)

I mean no disrespect.

I actually have studied the flash plugin quite a bit, as well as the Silverlight plugin, the common java plugins, and several others. Most of them work in the way I described. In fact, on my machine (and a few others that I have tested it on), Flash only installs in the registry, as you have noted.

There are a lot of reasons that you might want to install when a browser hasn't been installed. One is because they may install a different one than you are expecting. Chrome, Safari, and Opera are all good examples. However, not only that, but many plugins (Silverlight, for example) contain both a NPAPI(firefox) plugin and an ActiveX plugin all in the same file; in which case it makes perfect sense to install it so that either browser could use the same plugin.


You are correct that this way requires access to the registry; however, most computers require adminitrator access to write to the firefox home directory. Many developers forget about that, because they always are logged in as an admin user (hey, I do as well), but if you want your plugin to be installable in all cases, then it could be a problem.

The extension install method is the one that my second link (which I incorrectly added, aparently) described. Let me try it again:

Edit: I can't seem to include URLs, so I'll try cutting it apart:
http s :// developer.mozilla.org/en/Adding_Extensions_using_the_Windows_Registry - Adding Extensions using the Windows Registry
/Edit

The first link discussed plugin installation in the registry:

Edit:
http s:// developer.mozilla.org/En/Plugins/The_First_Install_Problem - The First Install Problem
/Edit

Installing extensions to a profile directory can in many cases be a good way to go; however, it is difficult to ensure that there will not be errors if you are writing to the profile directory (which generally speaking only firefox should be writing to, though this is of course debatable as well), and you have to worry about which profile to install it to (or install it in multiple locations) And, yes, there are suprisingly a lot of different reasons that someone would have multiple profiles on their machine.

When it comes down to it, how you decide to install should take a lot of things into account. When I look at the installer, I have to take into account that it will be installed on thousands of machines every month, and I need to catch every possible use case. If you have a smaller and more controlled userbase, it's not as big of an issue.

The method that we will be using (currently we use an XPI-based install, but it's causing some issues) is a hybrid. We register as a plugin and as an extension, both in the registry, and we register it as an ActiveX control. That way all NP-based browsers will work with it, though firefox 2 will not be able to detect it without a restart (firefox 2 only sees plugins installed in HKEY_LOCAL_MACHINE)