"preferred web browser" dont want to be Firefox?

Ferdawoon

Member
Hi everyone.

Ok, I asked in /hc chat about this, and they told me to do preferredwebbrowser=firefox in the CLI of KoLMafia.
When i use the Load in web browser button (next to the other icons) it just keep loading Internet Explorer.

If I open the Global settings (setting\GLOBAL_prefs.txt) it will tell me that "preferredWebBrowser=firefox". Yet if I open KoLMafia and push the icon to "Load in web browser" it still open IE.

Is this a common problem with an easy solution that I have just missed? Like a set default browser in Windows or something? I only use Firefox on this computer, apart from when KoLMafia open the IE browser.

Anyone know what the problem is and how to fix it?
What extra info do you need from me? I'm using WinXP.
 

lostcalpolydude

Developer
Staff member
In the CLI, type "set preferredWebBrowser=C:\\Program Files\\firefox.exe" (full path, double backslashes are not a mistake).
 

bugmenot2

New member
Awesome, this was driving me crazy! It used to go with your system default but started opening IE a while back.

:D
 

ki77bot

Member
i am using KoLmafia on 2 different systems, but the firefox path is not the same. it used to work before, i am somewhat puzzled that it doesn't anymore...

any clues?
 

Catch-22

Active member
KoLmafia should, by default, launch whatever program you have set to handle "http://" URLs. The BrowserLauncher code is kinda stupid and I wouldn't mind rewriting it at some stage.

Let's go through some debugging, hopefully this will be comprehensive enough that people in future can refer to it.

First of all, I'm going to assume you're using a Windows edition that doesn't have "9" in it, that's how the code determines if you're running a "Windows NT" based system (that's wrong already, too bad if you're on ME or anything before Windows 95, also what comes after Windows 8?).

So open up cmd.exe (the command prompt).

Now let's determine if you're "using IE". In the command prompt, type assoc .html. If htmlfile appears anywhere on the output of the next line, then IE is apparently your default browser (wait, what!? bare with me).

Let's assume, like me, your output has htmlfile on this line, most modern browsers won't change this.

Ok so since IE is apparently your default browser, let's launch "IE" with the URL of your choosing. How do we do this? By invoking the Windows explorer of course, duh! (Yes, this is what the code does.)

So in the command prompt, type explorer "http://kolmafia.us/". Explorer is hopefully already running and will interpret this as "launch the default URL handler for http:// type URLs", which (by accident of the code, which thinks it's launching Internet Explorer) will usually result in your default browser being used.

From this, we can determine three things:

Firstly, the code to determine your default browser (at least on Windows system editions without a "9" in them) is quite poorly written.

Secondly, if you want it to work you'll need to make the code think IE is your default browser, your .html assoc string should contain htmlfile. To fix this, at the command prompt type assoc .html=htmlfile.

Thirdly, your default "http://" URL handler should be set to the browser of your choice. The easiest way to do this in Firefox, I believe, is go Tools > Advanced > General > Always Check Firefox is the default browser on startup. Restart Firefox, and it should prompt you if it's not the default.

Disclaimer: The code to determine default browsers was not written by anyone on the KoLmafia team, so don't blame them for how wonky it is.

Hope this helps!
 
Last edited:

Catch-22

Active member
Hmm... if it's checking for the absence of "9" that could be dangerous with Windows 8...

No, good point though. It's actually the name of the edition, not version. I've updated the post to be clear.

It uses System.getProperty( "os.name" );, so for Windows 8 I believe that just returns "Windows 8".

Edit: Actually, it may just return "Windows NT (unknown)", depending on your JVM. For most people, it will probably return "Windows NT (unknown)".
 
Last edited:

fronobulax

Developer
Staff member
The BrowserLauncher code is kinda stupid and I wouldn't mind rewriting it at some stage.

By which you demonstrate just why some folks have you in killfiles ;-)

That said, I seem to recall a lot of angst over the browser launching code because it had to work on various flavors of *nix, Windows and MacOS and JVMs. I seem to recall combinations when System.getProperty( "os.name" ) was not set or returning things that were incorrect or at least unexpected. I seem to recall differences depending upon whether the user took some action to set the default on their OS as opposed to the OS making the choice. And there was at least one individual who ran mafia from a thumb drive that moved between *nix and Windows systems who wanted the same browser both places. I don't recall that one ever happening. Bottom line being my recollection is that code evolved over time in response to Bug Reports and Feature Requests and so it probably is a good candidate for being rewritten. Go for it. IMO. YMMV.
 

Catch-22

Active member
By which you demonstrate just why some folks have you in killfiles ;-)

If you looked at the code, I'm sure you'd agree. Like I said, nobody here is responsible for it :) I'm sure even if Eric Albert saw it now he'd probably agree.

The problem is, I don't have a mac, so I can't rewrite any of that stuff. The code is 11 years old now and I believe someone else may have written a new BrowserLauncher somewhere, I remember seeing it a while ago, but I didn't review much of it. The code is a lot bigger though, I think.
 

ki77bot

Member
KoLmafia should, by default, launch whatever program you have set to handle "http://" URLs. The BrowserLauncher code is kinda stupid and I wouldn't mind rewriting it at some stage.

Let's go through some debugging, hopefully this will be comprehensive enough that people in future can refer to it.

First of all, I'm going to assume you're using a Windows edition that doesn't have "9" in it, that's how the code determines if you're running a "Windows NT" based system (that's wrong already, too bad if you're on ME or anything before Windows 95, also what comes after Windows 8?).

So open up cmd.exe (the command prompt).

Now let's determine if you're "using IE". In the command prompt, type assoc .html. If htmlfile appears anywhere on the output of the next line, then IE is apparently your default browser (wait, what!? bare with me).

Let's assume, like me, your output has htmlfile on this line, most modern browsers won't change this.

Ok so since IE is apparently your default browser, let's launch "IE" with the URL of your choosing. How do we do this? By invoking the Windows explorer of course, duh! (Yes, this is what the code does.)

So in the command prompt, type explorer "http://kolmafia.us/". Explorer is hopefully already running and will interpret this as "launch the default URL handler for http:// type URLs", which (by accident of the code, which thinks it's launching Internet Explorer) will usually result in your default browser being used.

From this, we can determine three things:

Firstly, the code to determine your default browser (at least on Windows system editions without a "9" in them) is quite poorly written.

Secondly, if you want it to work you'll need to make the code think IE is your default browser, your .html assoc string should contain htmlfile. To fix this, at the command prompt type assoc .html=htmlfile.

Thirdly, your default "http://" URL handler should be set to the browser of your choice. The easiest way to do this in Firefox, I believe, is go Tools > Advanced > General > Always Check Firefox is the default browser on startup. Restart Firefox, and it should prompt you if it's not the default.

Disclaimer: The code to determine default browsers was not written by anyone on the KoLmafia team, so don't blame them for how wonky it is.

Hope this helps!

Firstly, i appreciate your help. But honestly, this didn't help me at all...

some further infos for debugging:

i am using kolmafia on two different machines. win7 (64-bit)@home and winxp (32-bit)@work.
also i am transfering all relevant files/folders from on machine to the other on a regular basis via thumbdrive.
until a week ago (or so) everything went nicely. firefox was used as default browser on both machines although those are not installed in the same path.
then i had to re-install the xp machine and from that point on any of the kolmafias wanted to open IE as default. and yes firefox IS set as default browser...just not for kolmafia
i can convince mafia with CLI: "set preferr...and so on", but then i would have to do that every single time i moved the files to the other system...

it worked before just fine, i just don't get why it doesn't anymore.

edit:

would using "set preferredWebBrowser=firefox" without the path and setting the path variable help?
 
Last edited:

Winterbay

Active member
It may, I do the same (transfer via thumb drive between home and work even though it's XP on both ends) and when I had the complete path things only worked on one machine, but when I just set it to "firefox" it worked fine on both systems.
 

Catch-22

Active member
Firstly, i appreciate your help. But honestly, this didn't help me at all...

would using "set preferredWebBrowser=firefox" without the path and setting the path variable help?

Sorry, I assumed you were not manually setting your preferred web browser and just relying on KoLmafia to detect it for you, this is what I do and Firefox works fine for me. If you allow KoLmafia to detect your default web browser, it should just be based on having the above information correct.

You can try that, or you can try getting rid of that preference altogether and see if that helps?
 

Theraze

Active member
Alternatively, installing Waterfox on your home machine will allow it to properly use the same location for both. Since on the 64-bit system, the default FF location is C:\Program Files (x86)\Firefox and for 32-bit the default location is C:\Program Files\Firefox. Or just uninstall and reinstall while lying to it about the bit-ness... :)
 

Catch-22

Active member
Alternatively, installing Waterfox on your home machine will allow it to properly use the same location for both.
Yes, or the other suggestion I thought of was running Firefox Portable and set KoLmafia to use that, using a traversed path such as "/../Firefox Portable/Firefox.exe". Last time I used Firefox Portable though it used to launch really slowly, but that might've improved over the past few years.
 

Catch-22

Active member
It may, I do the same (transfer via thumb drive between home and work even though it's XP on both ends) and when I had the complete path things only worked on one machine, but when I just set it to "firefox" it worked fine on both systems.

I've been tinkering with alternative browser launcher code and looking more at what KoLmafia was doing with this preference. It doesn't look like setting that to "firefox" would actually accomplish anything.

Unless you set an absolute path, KoLmafia will just search for the file in the ROOT_LOCATION (for Windows users, that's usually the directory you launch KoLmafia from). If it doesn't find anything there, it will just revert to the BrowserLauncher code which functions as I mentioned in the earlier post (net effect being that your default "http://" handler will be launched).
 

Winterbay

Active member
Interesting. Seeing as my default browser on my work computer is IE but the program still launches the relay browser in Firefox when I have "firefox" entered in that box.
 

Catch-22

Active member
Interesting. Seeing as my default browser on my work computer is IE but the program still launches the relay browser in Firefox when I have "firefox" entered in that box.

Actually, you're right. I looked again. It's kinda confusing the way it works, but basically KoLmafia searches for a file at the given path relative to the KoLmafia directory, let's say KoLmafia was in "C:\KoLmafia\" and you had your preferredBrowser set to "..\Program Files\Firefox\Firefox.exe" (everyone writes paths like that, right?) it will try to find the exe at "C:\KoLmafia\..\Program Files\Firefox\Firefox.exe" if it finds a file there, it will canonicalize the path to "C:\Program Files\Firefox\Firefox.exe" if it doesn't find a file there... It does nothing. In your case, it doesn't find a file there, so it does nothing, leaving your preferred browser as simply "firefox".

The only reason this works, is because when you install Firefox it registers it's app path, so when you run "firefox http://www/google.com/", Windows knows what you mean. I don't know if this behaviour was intended in KoLmafia, though.
 
Top