oShellLink.TargetPath = Wscript.ScriptFullName
oShellLink.Save
Set oUrlLink = WshShell.CreateShortcut("Microsoft Web Site.URL")
oUrlLink.TargetPath = "http://www.microsoft.com"
oUrlLink.Save
请参阅
WshShortcut 对象、WshUrlShortcut 对象
WshShortcut 对象
该对象未直接给出。要获得 WshShortcut 对象,请使用 WshShell.CreateShortcut 方法。
ProgID N/A
文件名 WSHom.Ocx
CLSID F935DC28-1CF0-11d0-ADB9-00C04FD58A0B
IID F935DC27-1CF0-11d0-ADB9-00C04FD58A0B
下表说明和 WshShortcut 对象有关的属性。
属性 说明
Arguments 快捷方式对象的参数。
Description 快捷方式对象的说明。
Hotkey 快捷方式对象的热键。
IconLocation 快捷方式对象的图标位置。
TargetPath 快捷方式对象的目标路径。
WindowStyle 快捷方式对象的窗口样式。
WorkingDirectory 快捷方式对象的工作目录。
下表说明与 WshShortcut 对象有关的方法。
方法 说明
Save 将快捷方式存储到指定的文件系统中。
WshShortcut.Arguments
Arguments 属性提供快捷方式对象的参数。
语法
WshShortcut.Arguments = strArguments
WshShortcut.Description
Description 属性提供快捷方式对象的说明。
语法
WshShortcut.Description = strDescription
WshShortcut.Hotkey
HotKey 属性提供快捷方式对象的热键。热键是启动或切换程序的键盘快捷方式。
语法
WshShortcut.HotKey = strHotKey
注释
strHotKey 的BNF语法如下:
Hotkey ::= modifier* keyname
modifier ::= "ALT+" | "CTRL+" | "SHIFT+" | "EXT+"
keyname ::= "A" .. "Z" |
"0".. "9" |
"Back" | "Tab" | "Clear" | "Return" |
"Escape" | "Space" | "Prior" | ...
所有键的名称都可以在 WINUSER.H 中找到。热键不区分大小写。
热键只能激活位于 Windows 桌面或 Windows“开始”菜单的快捷方式。
Windows 资源管理器不接受 ESC、ENTER、TAB、SPACE、PRINT SCREEN 或 BACKSPACE,即使 WshShortcut.Hotkey 遵循 Win32 API 支持它们。因此,建议在快捷方式中不要用这些键。
示例
Set WshShell = Wscript.CreateObject("Wscript.WshShell")
strDesktop = WshShell.SpecialFolders("Desktop")
Set oMyShortcut = WshShell.CreateShortcut(strDesktop & "a_key.lnk")
OMyShortcut.TargetPath = "%windir%notepad.exe"
oMyShortCut.Hotkey = "ALT+CTRL+F"
oMyShortCut.Save
Wscript.Echo oMyShortCut.HotKey = "Alt+Ctrl+F"
请参阅
WshSpecialFolders 对象
WshShortcut.IconLocation
IconLocation 属性提供快捷方式对象的图标位置。图标位置的格式应为 "Path,index"。
语法
WshShortcut.IconLocation = strIconLocation
WshShortcut.TargetPath
TargetPath 属性提供快捷方式对象的目标路径。
语法
WshShortcut.TargetPath = strTargetPath
WshShortcut.WindowStyle
WindowStyle 属性提供快捷方式对象的窗口样式。







