可以訪問 Windows 特殊文件夾集。
WshShell 對象的 SpecialFolders 屬性返回 WshSpecialFolders 對象(特殊文件夾集)。該文件夾集包含對 Windows 特殊文件夾的引用(例如,Desktop 文件夾、Start Menu 文件夾和 Personal Documents 文件夾)。它將特殊文件夾名稱用作索引,以便檢索特殊文件夾的路徑。特殊文件夾的路徑取決于用戶環(huán)境。特殊文件夾中存儲的信息對于登錄到計(jì)算機(jī)系統(tǒng)的用戶是唯一的。如果在同一計(jì)算機(jī)系統(tǒng)上為不同的用戶建立了帳戶,則硬盤上會存儲不同的特殊文件夾集。
以下特殊文件夾可用:
下面的腳本演示 WshSpecialFolders 對象的用法:
<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
</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();
</script>
</job>
</package>