CreateShortcut

CreateShortcut Method


Creates a new shortcut, or opens an existing shortcut.

object.CreateShortcut(strPathname) 

Arguments

object
WshShell object.
strPathname
String value indicating the pathname of the shortcut to create. 

 1       var WshShell = WScript.CreateObject("WScript.Shell");
 2          strDesktop = WshShell.SpecialFolders("Desktop");
 3          var oShellLink = WshShell.CreateShortcut(strDesktop + "\\Shortcut Script.lnk");
 4          oShellLink.TargetPath = WScript.ScriptFullName;
 5          oShellLink.WindowStyle = 1;
 6          oShellLink.Hotkey = "CTRL+SHIFT+F";
 7          oShellLink.IconLocation = "notepad.exe, 0";
 8          oShellLink.Description = "Shortcut Script";
 9          oShellLink.WorkingDirectory = strDesktop;
10          oShellLink.Save();
11          var oUrlLink = WshShell.CreateShortcut(strDesktop + "\\Microsoft Web Site.url");
12          oUrlLink.TargetPath = "http://www.microsoft.com";
13          oUrlLink.Save();

 

posted @ 2023-08-23 14:31  小风风的博客  阅读(55)  评论(0编辑  收藏  举报