Electronic Review of Computer Books

[ ERCB Home | New | Feature | Brief | DDJ | Letters | Links ]

[an error occurred while processing this directive]

Vital Statistics

Title Windows Script Host Programmer's Reference
Author Dino Esposito
Publisher WROX Press
http://www.wrox.com/
Copyright 1999
ISBN 1-861002-65-3
Pages 372
Price $29.99


A Worthy Work on WSH

Programs consisting of plain-text files that are interpreted or compiled on the fly have a relatively long history in computing, whether you call them scripts, batch files, or execs (as they're known on some IBM mainframe operating systems). In the DOS and Windows world, users have long been stuck with either stone-age .BAT files or third-party add-ons. The first option is limiting, and the second isn't a solution developers can depend on, since there's no guarantee a client machine will have the installed scripting language. But fairly recently Microsoft has addressed this issue, in the form of the Windows Script Host, which is included with Windows 98 and Windows 2000, and is available as a free download for Windows 95 and NT 4.0. (See "Scripts for Windows Scripting Host," by John Goalby, DDJ, January 1999.) The Windows Script Host natively supports two languages, VBScript and JScript, but the basic "engine" can be extended by third parties to support other languages. Despite its blatant usefulness, this new capability is one of the lesser known features added to Windows recently, a situation that is likely to change.

Windows Script Host Programmer's Reference, by Dino Esposito, provides an excellent introduction to the nooks and crannies of WSH, and there are plenty worth worrying about. The book contains 10 chapters: "What is the Windows Script Host?," "Windows Script Host Basics," "The WSH Root Object," "The WSH Object Model", "What's New in WSH 2.0", "Accessing the Windows File System," "Writing Reusable WSH Code," "Dialog Boxes and the User Interface," "A WSH Component Gallery," and "Windows Script Host Tidbits." There are also two appendices -- references for VBScript and JScript.

The general approach of this type of book can make or break it, and Esposito strikes just the right tone. He assumes that readers are reasonably capable Windows programmers, but are rank beginners with the WSH. Thus he explains early on how scripts are executed by Windows, with the obligatory (but still useful) box diagram, but never burdens the main part of the book with the tedious, blow-by-blow description of either JScript's or VBScript's syntax. He also refrains from making numerous references to the language-specific appendices. This creates a somewhat unusual atmosphere, as compared to that of most books of this type, but it's a very comfortable and productive one, nonetheless.

The author explains enough of the plumbing of the WSH and its object model, and how they interact with the facilities in the two supported languages, to give the reader a firm foundation. He routinely shows programming examples implemented in both VBScript and JScript, or shows one and describes the minimal changes to the other. While all such programming examples are inherently somewhat artificial, the examples in this book are well chosen, and in many cases will probably be "borrowed" directly into some reader's code.

I was particularly pleased to see the three chapters that focus on the new features in WSH 2.0, file system programming, and code reuse. Dealing with significantly different levels of a product can be an author's worst nightmare, but Esposito handles the situation well. Instead of walling-off all the 2.0-specific information in a separate section or chapter, he concentrates it in one chapter, but also mentions critical 1.0 versus 2.0 differences throughout the book. This could likely prevent hurried readers from picking up the book, spot-reading a page or two, and missing a relevant detail because it's squirreled away in the 2.0 chapter.

File system programming is another inescapable joy of programming, but sadly it's one that many authors don't like to address. Esposito talks at length about dealing with drives, folders, and individual files, as well as some of the nastier details, like how to go about replacing or moving an in-use file under Windows. He points out a bothersome NT versus Windows 9x issue, caused by the lack of access to the MoveFileEx() API.

My favorite part of the book is chapter 7, "Writing Reusable WSH Code." Reuse is a topic that gets far too little attention in computer books, and it was a relief to see it not only given its own chapter, but one that concentrates on the compatibility and real-world issues involved. For example, Esposito shows how to force WSH 1.0 scripts to use code in external files, via a minimal include() function he wrote. The technique isn't pretty, but it works. He then shows how WSH 2.0 handles this task much more gracefully.

The file handling and reuse chapters are the best examples of a subtlety that pervades this book, namely the feeling that it was written by a working programmer. Esposito clearly knows where a lot of the "gotcha's" are, and he takes the time to help the reader plot a course around them. Of course, any book of this sort can be criticized (fairly or otherwise) for not having more examples, particularly in the file-handling or dialog box areas. You can always think of additional, specific examples of trickier code that would be helpful, particularly when under time pressure on a critical project. And Esposito does commit the obligatory (some would say canonical) Windows error in version checking in one of his code samples, on page 277.

About my only other criticism of this book is the title -- it should serve quite well as a "programmer's reference," but I believe it will work just as well, if not better, as a tutorial that experienced programmers new to WSH should read cover to cover.

-- Lou Grinzo


Quick Rating

Readability Star Star Star
Originality Star Star Star
Organization Star Star Star
Accuracy Star Star Star
Consistency Star Star Star
Depth Star Star Star Star
Timeliness Star Star Star Star Star
Editing Star Star Star
Design Star Star Star
Overall Value Star Star Star

Explanation of ERCB rating scale: No stars = unacceptable, 1 Star = marginal, 2 Stars = average, 3 Stars = above average, 4 Stars = exceptional, 5 Stars = stellar.


Copyright © 1999 Electronic Review of Computer Books
Created 8/27/1999 / Last modified 8/27/1999 / webmaster@ercb.com