Problem creating a shorcut
Duncan Booth
duncan.booth at invalid.invalid
Fri May 16 09:34:42 EDT 2008
Tim Golden <mail at timgolden.me.uk> wrote:
>> 3) You assume, that Firefox is always installed at C:\Program
>> Files\Mozilla Firefox\firefox.exe
>> However the path largely differs from system to system.
>
> This is broadly true. However, it's fairly clear from the
> phrase "the user's desktop" that the OP is working in some
> kind of corporate environment where he can be fairly sure
> where Firefox is installed by policy. In addition, it's not so
> easy to find its path if it's not in the default place since apps
> very rarely add their location to the system PATH these days
> (and Firefox certainly doesn't). You could scan the registry for
> its App Paths entry in the registry but I don't know if any other
> way if it's not the default browser (which it's clear from the
> original post it may not be).
>
It's not too hard to get the required command line from the registry:
import _winreg
print _winreg.QueryValue(_winreg.HKEY_CLASSES_ROOT,
'FirefoxURL\shell\open\command')
and of course it throws an exception if firefox isn't installed.
Then just replace %1 with the url to get the actual command you need.
--
Duncan Booth http://kupuguy.blogspot.com
More information about the Python-list
mailing list