Unicode-aware file shortcuts in Windows
Neil Hodgson
nyamatongwe+thunder at gmail.com
Fri Sep 16 20:24:29 EDT 2005
Stanislaw Findeisen:
> E:\Documents and Settings\Staszek\Progs\Python-Windows\test_1>cf.py
> Traceback (most recent call last):
> File "E:\Documents and
> Settings\Staszek\Progs\Python-Windows\test_1\cf.py", line 7, in ?
> shortcut.Save()
> File "<COMObject <unknown>>", line 2, in Save
> pywintypes.com_error: (-2147352567, 'Exception occurred.', (0,
> 'WshShortcut.Save', 'Unable to save shortcut "E:\\Documents and
> Settings\\Staszek\\Progs\\Python-Windows\\test_1\\Te\x9a\xed me c\xfd
> z\xf3lazcseL\\link do vecer Z\xd3LAKe e\x9a\xed bla.lnk".', None, 0,
> -2147024893), None)
I see similar problems using WSH so I think the problem is in
WScript.Shell, rather than in Python's access to COM. Slightly
simplified and with the directory created:
<package>
<job id="js">
<script language="JScript">
WScript.Echo("Start")
var WshShell = WScript.CreateObject("WScript.Shell");
var oShellLink = WshShell.CreateShortcut("C:\\Těší mě čý
żółąźćśęŁ\\link do večer ŻÓŁĄKę ěší bla.lnk");
oShellLink.TargetPath = "c:\\bin\\bb.api";
oShellLink.Save();
WScript.Echo("End")
</script>
</job>
</package>
C:\bin>cscript ul.wsf
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
Start
C:\bin\ul.wsf(9, 11) WshShortcut.Save: Unable to save shortcut "C:\Teší
me cý zólazcseL\link do vecer ZÓLAKe eší bla.lnk".
C:\bin>dir c:\T*
Volume in drive C has no label.
Volume Serial Number is A04B-224D
Directory of c:\
02/06/2005 10:30 PM 67 test.py
17/09/2005 09:56 AM <DIR> Těší mě čý żółąźćśęŁ
1 File(s) 67 bytes
1 Dir(s) 7,014,309,888 bytes free
C:\bin>dir "c:\Těší mě čý żółąźćśęŁ"
Volume in drive C has no label.
Volume Serial Number is A04B-224D
Directory of c:\Těší mě čý żółąźćśęŁ
17/09/2005 09:56 AM <DIR> .
17/09/2005 09:56 AM <DIR> ..
0 File(s) 0 bytes
2 Dir(s) 7,014,309,888 bytes free
C:\bin>
Happy googling.
Neil
More information about the Python-list
mailing list