提供对本地 Windows 外壳程序的访问。
如果需要在本地运行程序、操纵注册表内容、创建快捷方式或访问系统文件夹,请创建 WshShell 对象。WshShell 对象提供 Environment 集。Environment 集可用来处理环境变量(如 WINDIR、PATH 或 PROMPT)。
下面的示例演示创建正在运行脚本的快捷方式和 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 方法