I have a short python script that is set as my default browser in the registry. It will choose to launch IE or Firefox based on the URL (Some work sites only function in IE). In the past, I just used a full path to the python installation to launch it, but this recently broke due to a change in the python install location (it is now bundled with our project files, so it may change more frequently). The path should be updated when it moves, so simply depending on the current environment to find python should be sufficient.

This is the old registry command entry:


@="\"C:\\Python26\\python.exe\" \"C:\\browser_chooser.pyw\" \"%1\""

Here's the best working option I have come up with so far:


@="\"C:\\Windows\\System32\\cmd.exe\" \"/c\" \"C:\\browser_chooser.pyw\" \"%1\""

However, this briefly pops up the command window when opening a link. I'd like to avoid that.

Without rewriting my script in another language and compiling it into an executable I can reference directly, is there a good way to get this to execute without knowing the path?


You would have to add the Python path to the system variable PATH or create a new system variable that is something like PYTHONDIR and have that point to the Python directory and then call the python.exe with %PYTHONDIR%\python.exe

PS. Why don't you use the Firefox Add-On IE Tabs?

  • I solve the IE problem with Google Chrome Frame - It lets (l)users continue to use IE, but will transparently render a site within IE using the Chrome engine whenever the site asks for it. My websites demand this plugin of my IE users. A clever solution to a horrible problem. Nov 15 '12 at 23:12
  • The python install directory is in PATH, which is why using cmd.exe works. Without a full path to the exe though, it can't be found. I will try IE tabs when I'm at the office tomorrow. Nov 16 '12 at 3:05
  • @RabbleRooster, that's strange because it works for me. I just created a test on my system doing what you are doing and it worked. Nov 16 '12 at 16:49
  • What was the syntax that leveraged the PATH? This doesn't work for me: @="\"python.exe\" \"C:\\browser_chooser.pyw\" \"%1\"" Nov 16 '12 at 20:32
  • @="python.exe \"c:\\test.py\" \"%1\"" Nov 16 '12 at 22:16

Can you use a .lnk file (i.e., a filesystem shortcut) in the open\command field in the registry?  If so, create a shortcut that runs your cmd /c command and has the “Run” control set to “Minimized”:

shortcut properties window with Run = Minimized circled

cmd.exe will still run, but it won’t pop up a window; it’ll only display a taskbar button.


If compiling without rewriting is an option, you can compile your python script into an exe with py2exe or pyinstaller- it'll compile it into a self contained exe and dlls you can use to run the application on its own with its own copy of python as a dll.

  • 1
    py2exe is pretty outdated. Probably better to use pyinstaller
    – ernie
    Nov 15 '12 at 23:52
  • ooh, wasn't aware of that. Edited it into my answer, thanks
    – Journeyman Geek
    Nov 15 '12 at 23:54
  • Anything is an option; this is a convenience tool. If I couldn't find a better option, I was going to go this route. This script had been passed around the office a bit, and I liked that people could edit it easily to modify the rules if needed. Nov 16 '12 at 3:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.