提供對本地 Windows 外殼程序的訪問。
如果需要在本地運行程序、操縱注冊表內容、創(chuàng)建快捷方式或訪問系統(tǒng)文件夾,請創(chuàng)建 WshShell 對象。WshShell 對象提供 Environment 集。Environment 集可用來處理環(huán)境變量(如 WINDIR、PATH 或 PROMPT)。
下面的示例演示創(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 </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>
CurrentDirectory 屬性 | Environment 屬性 | SpecialFolders 屬性
AppActivate 方法 | CreateShortcut 方法 | ExpandEnvironmentStrings 方法 | LogEvent 方法 | Popup 方法 | RegDelete 方法 | RegRead 方法 | RegWrite 方法 | Run 方法 | SendKeys 方法 | Exec 方法