WshShell Object 

Provides access to the native Windows shell.


Wsh Shell Object graphic

You create a WshShell object whenever you want to run a program locally, manipulate the contents of the registry, create a shortcut, or access a system folder. The WshShell object provides the Environment collection. This collection allows you to handle environmental variables (such as WINDIR, PATH, or PROMPT).


The following example demonstrates the creation of a shortcut to the script being run and a URL shortcut to


   <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




   <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;






CurrentDirectory Property | Environment Property | SpecialFolders Property


AppActivate Method | CreateShortcut Method | Exec Method | ExpandEnvironmentStrings Method | LogEvent Method | Popup Method | RegDelete Method | RegRead Method | RegWrite Method | Run Method | SendKeys Method

See Also


Running Your Scripts