Microsoft Windows Script Host 2.0 | 语言参考 |
返回 Windows 外壳文件夹的路径,如桌面文件夹,开始菜单文件夹,以及个人文档文件夹等。
非公开的;可通过 SpecialFolders 属性进行访问。用来取得桌面文件夹的位置,以便在桌面上创建快捷方式。
下例演示了如何在两个使用不同脚本语言(VBScript and JScript)的任务中使用同一个 .wsf 文件。这两个任务的功能相同——创建一个快捷方式,指向当前执行的脚本;一个 URL 快捷方式,指向 www.microsoft.com。
<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"
oUrlLink.Save
</script>
</job>
<job id="js">
<script language="Javascript">
var WshShell = new ActiveXObject("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";
oUrlLink.Save();
</script>
</job>
</package>
详细信息请参阅:运行脚本
Item 属性 | Count 属性 | Length 属性