Certainly! Below are concise descriptions and explanations for both the C# and Python solutions to open Firefox with a specific profile from Thunderbird. Although it is a workaround, it works perfectly for me. These descriptions aim to guide someone on how to create a small application in either programming language to achieve this task.
Finally, you then select your created .exe instead of the browser, which then starts the browser with your profile.
C# Solution
Opening Firefox with a Specific Profile from Thunderbird using C#
If you're looking to open Firefox with a specific profile from Thunderbird, one effective method is to create a small C# console application (.exe) that acts as an intermediary. This application will receive a URL as an argument and launch Firefox with the desired profile to open that URL. Here's how you can set it up:
Create a Console Application in Visual Studio: Start a new project and select "Console Application" as the project type. Choose either .NET Core or .NET Framework depending on your requirements.
Replace the Code in Program.cs: Use the following C# code snippet in your Program.cs file. This code checks for a URL argument, and if present, launches Firefox with the specified profile and URL.
using System;
using System.Diagnostics;
class Program
{
static void Main(string[] args)
{
string firefoxPath = @"C:\Program Files\Mozilla Firefox\firefox.exe";
string profilePath = @"N:\FIREFOX_PROFILE";
string url = args.Length > 0 ? args[0] : "";
if (!string.IsNullOrEmpty(url))
{
Process.Start(firefoxPath, $"-profile \"{profilePath}\" {url}");
}
else
{
Console.WriteLine("No URL provided.");
}
}
}
Adjust Paths Accordingly: Make sure to replace firefoxPath and profilePath with your actual Firefox executable and profile paths.
Compile and Use: Compile your project to generate an executable. You can then configure Thunderbird or your operating system to use this executable as the default browser, enabling links to open in Firefox with the specified profile.
Python Solution
Opening Firefox with a Specific Profile from Thunderbird using Python
For those preferring Python, you can achieve the same functionality by creating a small Python script. This script also serves as an intermediary, launching Firefox with a given profile when opening a URL from Thunderbird. Here’s a step-by-step guide:
Write Your Python Script: Save the following code as open_firefox_with_profile.py. This script accepts a URL as a command-line argument and launches Firefox with the specified profile to open that URL.
import sys
import subprocess
firefox_path = "C:\\Program Files\\Mozilla Firefox\\firefox.exe"
profile_path = "N:\\FIREFOX_PROFILE"
url = sys.argv[1] if len(sys.argv) > 1 else None
if url:
subprocess.run([firefox_path, "-profile", profile_path, url])
else:
print("No URL provided.")
Adjust Paths: Ensure the firefox_path and profile_path in the script match the paths on your system.
Make the Script Executable: Depending on your operating system, you might need to make the script directly executable. On Windows, you can convert this script to an executable (.exe) using tools like PyInstaller.
Integrate with Thunderbird: Configure Thunderbird or your system to use this script (or its compiled executable form) as the default browser. This allows opening links in Firefox with the desired profile.
Both solutions require adjusting system or Thunderbird settings to use the new executable or script as the default method for opening links. This enables you to open links from Thunderbird in Firefox with the specified profile, enhancing your workflow and browser organization.
Addendum: This setting must be made for http and https.
I couldn't find the http setting in the Thunderbird settings, so I had to do this manually in the Thunderbird profile folder (%appdata%\Thunderbird\profiles\{yourprofile}\handlers.json).
Unfortunately, the JSON is compressed and difficult to read (no breaks, spaces, etc.)
I use the editor Notpad++ and the "JSON Viewer" plugin for this.
This allows the JSON to be formatted in a readable format and then compressed again.
My schemes section looks like this:
"schemes": {
"https": {
"action": 2,
"handlers": [
{
"name": "mybrowser.exe",
"path": "C:\\{yourPath}\\mybrowser.exe"
},
{
"name": "firefox.exe",
"path": "C:\\Program Files\\Mozilla Firefox\\firefox.exe"
}
]
},
"http": {
"action": 2,
"handlers": [
{
"name": "mybrowser.exe",
"path": "C:\\{yourPath}\\mybrowser.exe"
},
{
"name": "firefox.exe",
"path": "C:\\Program Files\\Mozilla Firefox\\firefox.exe"
}
]
}
},