Newsreel
Products & Services
Web Watch
Software Update Resource Directory
Events Diary
Articles
The Magazine
Subscribe
Contact Us
Advertisers
TechEd reports
Exhibitors
Fun stuff |

Windows Script Host 2.0
July 8 - WSH is a host environment that is intended to replace batch files and batch
programming. It meets the expectations of both system administrators and seasoned users.
Through VBScript, JScript or any other supported script language you can automate almost
everything in Windows and access almost any publicly exposed object model. WSH is a
standard part of Windows 98 and comes as a separate add-on for both Windows 95 and Windows
NT 4.0.
The new version of WSH presents a number of interesting and useful
features. The WSH 2.0 will ship with Windows 2000 and will also be made available as an
add-on for other platforms. At the moment, WSH 2.0 is in beta 2 which is a step forward
from the WSH beta that ships with the latest beta of Windows 2000.
What's New in WSH 2.0
WSH 2.0 addresses four of the most frequent requests from users: includes, type libraries,
multiple engines, and tools support. These are just the highlights, though. WSH 2.0 is
much more. Since WSH 1.0 was just an interpreter for VBScript or JScript files, the files
processed must necessarily be .vbs or .js, with no means of importing code from external
sources. As you can see, it is a significant drawback that reduces the possibility of
reusing code. WSH 2.0 supports a new, XML-based, file format that lets you define as many
<script> blocks as you want, each of which can make use of a different language and
can specify an external file as the source.
<script language ="VBScript" src="myfile.vbs" />
<script language ="JScript" />
</script>
Other tags that the new WS file format allows are <reference>
and <object>. The former lets you reference a type library importing the constants
that are included. For example, if you need to bind to, say, ADO then you can use the
ADO-specific constants without using one line of code. The <object> tag lets you
create global instances of COM objects that are shared by all the <script> tags in a
file. You can also have more batch jobs in the same file. In this case, each job holds its
own set of <object>, <reference>, and <script> tags.
Changes in the WSH Object Model
The latest beta of WSH 2.0 also adds new methods to the existing objects. For example,
you can now send keystrokes to applications obtaining a simple form of interaction between
WSH and applications (e.g. Notepad) that
dont expose an object model. This method is WshShell.SendKeys. You can also manage
the standard I/O devices through text stream objects such as StdIn, StdOut and StdErr.
You're given a chance to pause a script using the Sleep method and also have an improved
shell support through drag-and-drop. As a result, you can drag-and-drop files from the
shell over a VBS or JS file and have it receive them as command line arguments. Finally,
you can log events from your WSH script directly to the Windows NT Event Viewer.
Summary
WSH is an important development environment that fixes a historical deficiency in
the Windows platform: a Windows-specific batch file. Now VBS, JS and WS files are
executables that let you automate repetitive tasks, accessing almost all the features of
Windows, from the registry to the network and from the standard I/O devices to the file
system.
Dino Esposito
|
|