Mike Driscoll wrote: > 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('WScript.Shell') > userDesktop = winshell.desktop() > > shortcut = shell.CreateShortCut(userDesktop + > '\\MyShortcut.lnk') shortcut.Targetpath = r'"C:\Program > Files\Mozilla Firefox\firefox.exe" > https:\www.myCompanyWebsite.com\auth\preauth.php' > shortcut.WorkingDirectory = r'C:\Program Files\Mozilla Firefox' > shortcut.save() > > </code> > > This creates the following target path (which doesn't work): > > "C:\"C:\Program Files\Mozilla Firefox\firefox.exe" https: > \www.myCompanyWebsite.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.
I see four problems: 1) you should not hardcode the backslashes ('\'), instead use os.sep for it. 2) In URIs there are no backslashes, only forward slashes. You coded https:\... which is _WRONG_. URIs are <protocoll>://<host>/<resource>, where for some protocolls <host> is empty (file protocoll e.g.). 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. On *nix systems you normally have all programs in $PATH, so a non full qualified path would be sufficient. On Windows this works, too, _IF_ the installation directory of the to be used application get's added to the PATH environment variable. Wolfgang Draxinger -- E-Mail address works, Jabber: [EMAIL PROTECTED], ICQ: 134682867 -- http://mail.python.org/mailman/listinfo/python-list