Getting Started
Windows Scripting Host (WSH), what is it?
WSH, simply put, allows you to develop scripts using traditionally,
browser based scripting languages such as JavaScript and VBScript.
Our Unix counterparts have enjoyed a number of good scripting
languages for years. Now the Windows world can join the rest
of the world by having a scripting language it can call its own.
Microsoft has provided software developers a way to add scripting
capabilities to their applications through ActiveX Scripting. WSH
is one such applications. Developers can now easily add scripting
capabilites to their what ever they are developing. If this
becomes widely accepted, it could lead a huge new area for scripters
around the world.
How do I get started?
First you will need to download the WSH installation from Microsoft.
Microsoft's Scripting Site
When you install this package a couple of things happen.
- WScript.exe and CScript.exe are installed
- WSH.ocx is register as a COM object
- Sample scripts are installed
What do WScript.exe and CScript.exe do?
WScript.exe is the Windows executable for WSH. It allow you to use
a few basic GUI controls, such as Popup Dialog Boxes.
CScript.exe is the command line executable for WSH.
Depending on how a script was written, it can be run under both
WScript.exe and CScript.exe and produce the same results. For example,
running
WScript.Echo( "hello" );
using WScript would generate a dialog box with hello displayed.
Using CScript would print hello at the prompt.
What functionality does WSH.OCX give me?
The true power of WSH lies in its ability to instanciate (create)
COM objects. WSH.OCX provides a basic set of utilities that you
will use often. The objects provided by WSH are as follows:
- WshShell
- WshNetwork
- WshShortcut
- WshCollection
- WshEnvironment
- WshSpecialFolders
Two additional objects are provided by WScript.exe:
Refer to WSH's Object Model for
additional information.
If WSH can instantiate (Create) COM objects, can I use other COM objects?
Yes, you certainly can. In fact, WSH is some what limited compared
to other scripting languages with using objects.
There is already a huge number of COM objects already on your system just
waiting for you to use. A number of these COM objects are installed with
Windows, while most are part of other applications. The COM objects
that are available on your system will vary depending on which version
of Windows you are using and what applications you have installed.
To see what is available on your system, you can use tools such as OLEView
and XRay. Check the introduction to using the OLEView utilitiy under
howto/tools