[python-win32] Re: How to create Windows directory shortcut from Python (answered)

Mark Hammond mhammond@skippinet.com.au
Tue, 8 Apr 2003 08:56:12 +1000


While this is fine, it can be done without wshell - win32com.shell contains
all you need, and I have posted such solutions to comp.lang.python a number
of times.

Mark

> -----Original Message-----
> From: python-win32-admin@python.org
> [mailto:python-win32-admin@python.org]On Behalf Of G. Ken Holman
> Sent: Wednesday, 19 March 2003 1:24 PM
> To: python-win32@python.org
> Subject: [python-win32] Re: How to create Windows directory shortcut
> from Python (answered)
>
>
> With many thanks to Paul Prescod who related the answer to me off-list, I
> downloaded the Windows extensions found at:
>
>     http://starship.python.net/crew/mhammond/win32/
>
> and used the following code that created a directory shortcut on
> my T drive
> named "test" that points to the "ftemp" directory (also on T):
>
> import sys
> import win32com.client
>
> shell = win32com.client.Dispatch("WScript.Shell")
> shortcut = shell.CreateShortCut("t:\\test.lnk")
> shortcut.Targetpath = "t:\\ftemp"
> shortcut.save()
>
> Note that when I used "/" instead of "\\" in the pathnames the
> shortcut was
> *not* created properly.
>
> At 2003-03-17 15:34 -0500, I wrote:
> >Hi!
> >
> >I'm wondering if anyone has figured out how to create a Windows
> directory
> >shortcut (Windows equivalent of a linked directory) from within a Python
> >application.
> >
> >I can create a shortcut from the Windows Explorer by a right-click copy
> >and selecting "Create Shortcuts Here" ... I'm looking for a Python
> >solution to do the same action.
> >
> >I had anticipated the Windows implementation of os.symlink() would have
> >done it, but there appears to be no implementation of os.symlink() under
> >Windows.
> >
> >I could find nothing in a search of the archive of this list.
> >
> >Thanks for any help you can be!
> >
> >................. Ken
>
>
> --
> Upcoming hands-on in-depth XSLT/XPath and/or XSL-FO
>                               North America:      June 16-20, 2003
>
> G. Ken Holman                mailto:gkholman@CraneSoftwrights.com
> Crane Softwrights Ltd.         http://www.CraneSoftwrights.com/z/
> Box 266, Kars, Ontario CANADA K0A-2E0   +1(613)489-0999 (F:-0995)
> ISBN 0-13-065196-6                      Definitive XSLT and XPath
> ISBN 0-13-140374-5                              Definitive XSL-FO
> ISBN 1-894049-08-X  Practical Transformation Using XSLT and XPath
> ISBN 1-894049-10-1              Practical Formatting Using XSL-FO
> Male Breast Cancer Awareness http://www.CraneSoftwrights.com/z/bc
>
>
> _______________________________________________
> Python-win32 mailing list
> Python-win32@python.org
> http://mail.python.org/mailman/listinfo/python-win32
>