To create a shortcut, use the CreateShortcut Method of a WshShell Object.
The following example code creates a shortcut on the desktop to an opened file.
if( document.FullName == "" ) {
alert( "The file is untitled." );
}
else {
WshShell = new ActiveXObject( "WScript.Shell" );
strDesktop = WshShell.SpecialFolders("Desktop");
oShellLink = WshShell.CreateShortcut(strDesktop + "\\Shortcut
to My File.lnk");
oShellLink.TargetPath = document.FullName;
oShellLink.WindowStyle = 1;
oShellLink.Description = "Shortcut to My File";
oShellLink.WorkingDirectory = strDesktop;
oShellLink.Save();
}
If document.FullName = "" Then
alert "The file is untitled."
Else
Set WshShell = CreateObject( "WScript.Shell" )
strDesktop = WshShell.SpecialFolders("Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop &
"\Shortcut to My File.lnk")
oShellLink.TargetPath = document.FullName
oShellLink.WindowStyle = 1
oShellLink.Description = "Shortcut to My File"
oShellLink.WorkingDirectory = strDesktop
oShellLink.Save
End If
Microsoft MSDN Library: CreateShortcut Method
Send feedback on this topic to Emurasoft