Re: Can't create shortcut whose name contains Unicode?



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.

.



Relevant Pages

  • Re: help writting script to copy file to every desktop
    ... Then it will ping each computer to see if it is truly reachable. ... Here is a sample script that I use. ... Each shortcut is only 1KB each, so the extra replication traffic is nothing. ... You will get different methods, collections, and properties for a file than you will for a folder. ...
    (microsoft.public.scripting.vbscript)
  • Re: help writting script to copy file to every desktop
    ... I added the script to the policy assigned to the OU. ... Each shortcut is only 1KB each, so the extra replication traffic is nothing. ... You will get different methods, collections, and properties for a file than you will for a folder. ... ' Create a collection of files in the folder object ...
    (microsoft.public.scripting.vbscript)
  • Re: Shortcut on desktop via logon?
    ... I've been asked to distribute a shortcut to a web site to all my users. ... From this line I get no response in my batch file output. ... the script will be unable to succeed as the logon ... the workstations while logged in to an account that is an admin on all ...
    (microsoft.public.windows.server.scripting)
  • Re: help writting script to copy file to every desktop
    ... Here is a sample script that I use. ... You should be able to limit the scope of the copy by creating multiple versions of this script and assign them to the group policy assigned to each AD site. ... Each shortcut is only 1KB each, so the extra replication traffic is nothing. ... You will get different methods, collections, and properties for a file than you will for a folder. ...
    (microsoft.public.scripting.vbscript)
  • Re: GPO to set desktop preferences ?
    ... course there are a lot of automation options available such as a script to ... simply a registry modification and if so script it or create a custom ADM ... file to have the setting managed through Group Policy. ... For the deployment of the shortcut try somethign like this... ...
    (microsoft.public.windows.group_policy)