Page 1 of 2

Firefox is the default browser for all users

Published: September 19, 2016 - 9:01 PM
by Matthew
Hello,
I'd like to set up a package that restores Firefox as the default browser for all users on a computer.
After some research and testing on one machine, the most effective command seems to be
`C:\Program Files\Mozilla Firefox\uninstall\helper.exe /SetAsDefaultGlobal`.

So I created a package that runs this command with:
`run(r'C:\Program Files\Mozilla Firefox\uninstall\helper.exe /SetAsDefaultGlobal')`.

However, it seems to work on some machines but not others.

After investigating, I suspect it's related to User Account Control (UAC).
I therefore modified the registry before running the command, but it appears that a restart is required for the command to take effect.

My question is: I plan to create two packages: the first disables UAC, and the second restores Firefox as the default browser. How can I ensure a restart occurs between the installation of the two packages?

Thank you

, Matthieu

Re: Firefox as default for all users

Published: September 22, 2016 - 5:41 PM
by the Challans Town Hall
Good morning,

Here are the commands to integrate into your setup.py to do this:

For x64 systems:

Code: Select all

"C:\Program Files (x86)\Mozilla Firefox\uninstall\helper.exe" /SetAsDefaultAppGlobal
For x86:

Code: Select all

"C:\Program Files\Mozilla Firefox\uninstall\helper.exe" /SetAsDefaultAppGlobal
To help you build the script, you may need the functions below:

Code: Select all

makepath(programfiles32,'Mozilla Firefox','uninstall','helper.exe')
As well as the example below for concatenating and running the command

Code: Select all

command = r"powershell -NoProfile -NoLogo -NonInteractive -Command import-startlayout -layoutpath screenlayout.bin -mountpath "
path = os.path.normpath('C:\\')
commandsm = ''.join([command,path])
run(commandsm)
Problem observed:
Some Windows updates reset Internet Explorer to default
So, a word of advice: create this package independently of the name, using `tis-firefoxdefaultall`, and place it as a dependency on the main Firefox package
Because this way, to restore Firefox to default, you just need to regenerate a version of tis-firefoxdefaultall which will restore Firefox to default without reinstalling Firefox.

Re: Firefox as default for all users

Published: September 23, 2016 - 9:55 PM
by Matthew
THANKS,
I'll be back with several tests.
If I understand correctly, this is what I need to write in the package:

Code: Select all

commande = makepath(programfiles32,'Mozilla Firefox','uninstall','helper.exe')
parametre = '/SetAsDefaultAppGlobal'
commandsm = ' '.join([commande,parametre])
run(commandsm)
Why can't I just do it?

Code: Select all

run(r'C:\Program Files (x86)\Mozilla Firefox\uninstall\helper.exe /SetAsDefaultAppGlobal')
?

Re: Firefox as default for all users

Published: March 22, 2018 - 10:51
by gaelds
Has anyone succeeded?

The code

Code: Select all

            commande = makepath(programfiles,'Mozilla Firefox','uninstall','helper.exe')
           parametre = '/SetAsDefaultAppGlobal'            
           commandsm = ' '.join([commande,parametre])
            run(commandsm)
makes me:
CalledProcessErrorOutput: Command 'C:\\Program Files\\Mozilla Firefox\\uninstall\\helper.exe /SetAsDefaultAppGlobal' returned non-zero exit status 1.
Output: 'C:\Program' is not recognized as an internal
or external command, operable program or batch file.


and a simple run

Code: Select all

run_notfatal(r'"C:\Program Files\Mozilla Firefox\uninstall\helper.exe" /SetAsDefaultAppGlobal')
yields: FATAL ERROR: CalledProcessErrorOutput: Command '"C:\\Program Files\\Mozilla Firefox\\uninstall\\helper.exe" /SetAsDefaultAppGlobal' returned non-zero exit status 2.
Output:
Exit code: 3

Re: Firefox as default for all users

Published: March 22, 2018 - 11:00 AM
by agauvrit
Good morning,

While reading: http://kb.mozillazine.org/Default_browser#Windows

Code: Select all

firefox.exe -silent -setDefaultBrowser
Seems more appropriate. Launch it in the session_setup() section of the Firefox package and it should work for all users.

For those interested, Firefox 60 is coming this summer with a set of GPO templates that can be integrated into AD (ADMX files): Alexander

Re: Firefox as default for all users

Published: March 22, 2018 - 11:12
by gaelds
Sorry to be a pain, but the following code:

Code: Select all

run(r'"C:\Program Files\Mozilla Firefox\firefox.exe" -silent -setDefaultBrowser"')
yields:
FATAL ERROR: CalledProcessErrorOutput: Command '"C:\\Program Files\\Mozilla Firefox\\firefox.exe" -silent -setDefaultBrowser"' returned non-zero exit status 1.

I'm moving the quotation marks and apostrophes around, but nothing is working...

Re: Firefox as default for all users

Published: March 22, 2018 - 11:33
by agauvrit
The last quotation mark is unnecessary

Re: Firefox as default for all users

Published: March 22, 2018 - 11:39
by gaelds
Ah yes, indeed, but even after correcting it I still have an error...

Code: Select all

run(r'"C:\Program Files\Mozilla Firefox\firefox.exe" -silent -setDefaultBrowser')
FATAL ERROR: CalledProcessErrorOutput: Command '"C:\\Program Files\\Mozilla Firefox\\firefox.exe" -silent -setDefaultBrowser' returned non-zero exit status 1.

Re: Firefox as default for all users

Published: March 22, 2018 - 2:39 PM
by agauvrit
Good morning,

Would it be possible to install Firefox 32 on the posts?

The call path would then be C:\Program Files (x86\Mozilla Firefox\

I wasn't up to date on the new procedure for setting the default browser in Windows 10:
I haven't found any other functional "scriptable" methods under Windows 10 for Firefox, except by using a third-party executable: https://github.com/sampalmer/set-default-browser

Worth testing, but it's preferable to use a GPO.

Alexander

Re: Firefox as default for all users

Published: March 22, 2018 - 2:49 PM
by gaelds
Until yesterday, I was installing a 32-bit Firefox package everywhere, but the latest "lesfourmisduweb" packages uninstalled this 32-bit version and installed the 64-bit one. A folder called "C:\Program Files (x86)\Mozilla Firefox" remains on the computers, but it's almost empty.
And there's no longer a default browser on the computers, so users can no longer open website shortcuts on their desktops...