將快捷方式對(duì)象保存到磁盤中。
object.Save
使用 CreateShortcut 方法創(chuàng)建快捷方式對(duì)象并設(shè)置快捷方式對(duì)象的屬性后,必須用 Save 方法將快捷方式對(duì)象保存到磁盤中。Save 方法使用快捷方式對(duì)象的 FullName 屬性中的信息,確定快捷方式對(duì)象在磁盤上的保存位置。只可創(chuàng)建系統(tǒng)對(duì)象的快捷方式,包括文件、目錄和驅(qū)動(dòng)器(不包括打印機(jī)鏈接或調(diào)度任務(wù))。
下面的示例演示如何將一個(gè) .wsf 文件用于以不同腳本語(yǔ)言(VBScript 和 Jscript)寫成的兩個(gè)作業(yè)。每個(gè)作業(yè)都創(chuàng)建正在運(yùn)行腳本的快捷方式,并創(chuàng)建 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>
運(yùn)行腳本 | WshShortcut 對(duì)象 | WshUrlShortcut 對(duì)象 | FullName 屬性 | TargetPath 屬性 | WindowStyle 屬性 | Hotkey 屬性 | IconLocation 屬性 | Description 屬性 | WorkingDirectory 屬性