Windows Scripting Host
Using the Windows Scripting Host (WSH) is
much easier than you think! Julian Moss explains how, in this practical guide
from PC Support Advisor.
This is a plain html version of
the original article. For the original version in PDF format complete with pictures,
click here.
One of Windows’s most notable deficiencies
when compared with other operating systems is its lack of a batch language for
automating tasks. Although the underlying MS- DOS supports batch files, they
are of little use in the Windows environment: you can’t even launch Windows
programs from batch files.
Support staff wishing to automate tasks for their users have been forced to
use third- party tools like Wilson WinBatch or JP Software’s Take Command. Because
these tools are not part of Windows, they must be separately installed before
they can be used. Licensing of these tools means that additional costs are often
incurred, which, if the budget is not available, becomes a problem.
This limitation of Windows was removed with the advent of the Windows Scripting
Host (WSH). Available since the release of Internet Explorer 3. 0, Microsoft
originally kept quiet about the facility. This is no longer the case, and the
WSH is one of the standard accessories in Windows 98. It can be also be
downloaded from http://www.microsoft.com/scripting
to install on Windows 95 and NT 4.
Documentation for the Microsoft script engines can be viewed online at
http://www.microsoft.com-/
scripting/ start.HTM
Scripting Architecture
Internet Explorer 3.0 introduced the capability of client- side scripting, using
script code embedded in HTML pages. Instead of making this a dedicated feature
of Internet Explorer, Microsoft designed the facility in such a way that scripting
could be incorporated into other applications as well. The application - in
this case Internet Explorer - is the scripting host, and exposes various COM
objects that a script can manipulate.
In the WSH, the objects that are provided allows scripts to control certain
features of the operating system. Microsoft produces one other scripting host:
Internet Information Server (IIS), which uses the same script language for serverside
scripting. Other developers may also write applications that are scripting hosts
since Microsoft has published the specification for doing so.
Microsoft has also documented the interface for script engines. This will allow
developers to write engines for other script languages. Once the engines are
registered with the system these script languages can be used in any scripting
host. Microsoft has produced two script languages, VBScript and JavaScript.
Engines for other popular script languages like Perl and Rexx will doubtless
soon appear. In this article we will focus on using VBScript, but all of the
examples given here could be implemented equally well using JavaScript.
Windows Scripting Host page
2
|