Re: Can't create shortcut whose name contains Unicode?
- From: "Alex K. Angelopoulos" <aka(at)mvps.org>
- Date: Wed, 7 May 2008 16:22:27 -0400
Found a fix. From running this in Dependency Walker, it appears that the problem is the Save() method in WshShell's shortcut object. It appears that it explicitly uses ANSI functions in OleAut32.dll to create the file, thus choking on the wide characters.
Although you can't create the shortcut with the name you want, you can still create the shortcut and then rename it. I didn't try using the Scripting.FileSystemObject, but using cmd.exe's rename command worked fine. Below is my example; since I'm using one of the Latin ISO sets in news, your filename may be mangled, but I think you get the picture. I included a brief wait in the script to ensure that the filename is available before I try the rename operation; this might not be necessary in practice.
<?xml version="1.0" encoding="UTF-8" ?>
<job id="ShortcutMaker">
<script language="JScript">
<![CDATA[
var WshShell = WScript.CreateObject("WScript.Shell");
var oShellLink = WshShell.CreateShortcut("C:\\This works.lnk");
oShellLink.TargetPath = "C:\\Windows\\Notepad.exe";
oShellLink.IconLocation = "Notepad.exe, 0";
oShellLink.Save();
WScript.Sleep(3000);
WshShell.Run('cmd /c rename "C:\\This works.lnk" 馬鹿な.lnk');
]]>
</script>
</job>
"Cat" <typingcat@xxxxxxxxx> wrote in message news:c21c8d96-cc6a-48cc-a6c5-a1591f7c11d5@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
var oShellLink = WshShell.CreateShortcut( path+ "\\Some Asian
characters.lnk");
...
ShellLink.Save();
I created a simple wsf script using NotePad. I even saved it in UTF-8
encoding. But the code above fails because the scripting engine cannot
understand the Asian characters.
Error : Unable to save shortcut ".....??????.lnk".
Code 8007007B
Is there any way to create a shortcut in Unicode using WSH? If it is
impossible, please tell me also, then I can start finding another way.
Thank you.
.
- References:
- Prev by Date: Re: Can't create shortcut whose name contains Unicode?
- Next by Date: Can't connect to remote computer.
- Previous by thread: Re: Can't create shortcut whose name contains Unicode?
- Next by thread: Can't create shortcut whose name contains Unicode?
- Index(es):
Relevant Pages
|
|