可以访问 Windows 特殊文件夹集。
WshShell 对象的 SpecialFolders 属性返回 WshSpecialFolders 对象(特殊文件夹集)。该文件夹集包含对 Windows 特殊文件夹的引用(例如,Desktop 文件夹、Start Menu 文件夹和 Personal Documents 文件夹)。它将特殊文件夹名称用作索引,以便检索特殊文件夹的路径。特殊文件夹的路径取决于用户环境。特殊文件夹中存储的信息对于登录到计算机系统的用户是唯一的。如果在同一计算机系统上为不同的用户建立了帐户,则硬盘上会存储不同的特殊文件夹集。
以下特殊文件夹可用:
下面的脚本演示 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>