Hi,
I've had this niggling issue from time to time. I want to create a
shortcut on the user's desktop to a website that specifically loads
Firefox even if Firefox is not the default browser.
I usually use COM as it allows very specific settings of the shortcut,
such as the Working Directory and the Target Path. However, the
following will not work for some reason:
<code>
import win32com.client
import winshell
shell = win32com.client .Dispatch('WScr ipt.Shell')
userDesktop = winshell.deskto p()
shortcut = shell.CreateSho rtCut(userDeskt op + '\\MyShortcut.l nk')
shortcut.Target path = r'"C:\Program Files\Mozilla Firefox\firefox .exe"
https:\www.myCo mpanyWebsite.co m\auth\preauth. php'
shortcut.Workin gDirectory = r'C:\Program Files\Mozilla
Firefox'
shortcut.save()
</code>
This creates the following target path (which doesn't work):
"C:\"C:\Pro gram Files\Mozilla Firefox\firefox .exe" https:
\www.myCompanyW ebsite.com\auth \preauth.php"
If I leave the website off, it works. If I leave the path to Firefox
out, it works too. Is there another method I can use other than
creating the shortcut by hand and using the shutil module?
Thank you for any ideas.
Mike
I've had this niggling issue from time to time. I want to create a
shortcut on the user's desktop to a website that specifically loads
Firefox even if Firefox is not the default browser.
I usually use COM as it allows very specific settings of the shortcut,
such as the Working Directory and the Target Path. However, the
following will not work for some reason:
<code>
import win32com.client
import winshell
shell = win32com.client .Dispatch('WScr ipt.Shell')
userDesktop = winshell.deskto p()
shortcut = shell.CreateSho rtCut(userDeskt op + '\\MyShortcut.l nk')
shortcut.Target path = r'"C:\Program Files\Mozilla Firefox\firefox .exe"
https:\www.myCo mpanyWebsite.co m\auth\preauth. php'
shortcut.Workin gDirectory = r'C:\Program Files\Mozilla
Firefox'
shortcut.save()
</code>
This creates the following target path (which doesn't work):
"C:\"C:\Pro gram Files\Mozilla Firefox\firefox .exe" https:
\www.myCompanyW ebsite.com\auth \preauth.php"
If I leave the website off, it works. If I leave the path to Firefox
out, it works too. Is there another method I can use other than
creating the shortcut by hand and using the shutil module?
Thank you for any ideas.
Mike
Comment