将快捷方式对象保存到磁盘中。
object.Save
使用 CreateShortcut 方法创建快捷方式对象并设置快捷方式对象的属性后,必须用 Save 方法将快捷方式对象保存到磁盘中。Save 方法使用快捷方式对象的 FullName 属性中的信息,确定快捷方式对象在磁盘上的保存位置。只可创建系统对象的快捷方式,包括文件、目录和驱动器(不包括打印机链接或调度任务)。
下面的示例演示如何将一个 .wsf 文件用于以不同脚本语言(VBScript 和 Jscript)写成的两个作业。每个作业都创建正在运行脚本的快捷方式,并创建 www.microsoft.com 的 URL 快捷方式。
<package>
<job id="vbs">
<script language="VBScript">
set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop & "\Shortcut Script.lnk")
oShellLink.TargetPath = WScript.ScriptFullName
oShellLink.WindowStyle = 1
oShellLink.Hotkey = "CTRL+SHIFT+F"
oShellLink.IconLocation = "notepad.exe, 0"
oShellLink.Description = "Shortcut Script"
oShellLink.WorkingDirectory = strDesktop
oShellLink.Save
set oUrlLink = WshShell.CreateShortcut(strDesktop & "\Microsoft Web Site.url")
oUrlLink.TargetPath = "http://www.microsoft.com/china"
oUrlLink.Save
</script>
</job>
<job id="js">
<script language="JScript">
var WshShell = WScript.CreateObject("WScript.Shell");
strDesktop = WshShell.SpecialFolders("Desktop");
var oShellLink = WshShell.CreateShortcut(strDesktop + "\\Shortcut Script.lnk");
oShellLink.TargetPath = WScript.ScriptFullName;
oShellLink.WindowStyle = 1;
oShellLink.Hotkey = "CTRL+SHIFT+F";
oShellLink.IconLocation = "notepad.exe, 0";
oShellLink.Description = "Shortcut Script";
oShellLink.WorkingDirectory = strDesktop;
oShellLink.Save();
var oUrlLink = WshShell.CreateShortcut(strDesktop + "\\Microsoft Web Site.url");
oUrlLink.TargetPath = "http://www.microsoft.com/china";
oUrlLink.Save();
</script>
</job>
</package>
运行脚本 | WshShortcut 对象 | WshUrlShortcut 对象 | FullName 属性 | TargetPath 属性 | WindowStyle 属性 | Hotkey 属性 | IconLocation 属性 | Description 属性 | WorkingDirectory 属性