Help. Almost every decent console tool has a command-line Help switchtypically /? or /hthat you can use to access information. In XP and Win2K, you can call up the general command-line Help with the following command at a command prompt:
HH ntcmds.chm
In addition, the CliWrapper class has a couple of helpful mechanisms. It has a Command property that lets you see your command the same way Windows sees it. If something isn't running as you expect, try using the following statement to see the command exactly as executed:
WScript. Echo console.command
In addition, you can echo the script's error output using
WScript. Echo console.stderr
Finally, you can instantly reuse the console object by simply calling console.exec with a new command string. You don't need to add another New statement because the console will automatically clean up its old output each time it's called.
The Right Tool for the Task
The CliWrapper class makes console-application-output capture simple by hiding complex implementation concerns. We haven't addressed an important question, however: Is hiding these concerns a good thing to do? Obviously, the WSH designers thought so because in WSH 5.6, WScript.Shell's Exec method provides some support for this approach.
Command-line tools have a lot to offer. First, they're usually efficient and reliable. The command shell takes minimal overhead, and console tools typically perform only a handful of specific lightweight API calls. Because they don't need to display and scroll data, when these tools are wrapped up they can actually be faster than usual.
Second, console tools are long-lived. Some have been around for almost 20 years and no longer have any rough edges.
Third, console tools are well designed for administrative scripting. Generally speaking, administrative scripting tasks involve linear decision making and filtering, and data is focused on large-scale system parameters. In contrast, most of the scriptable COM objects are designed first and foremost for programmers and thus can require a significant amount of coding to make them do what you want.
Ultimately, to determine whether a command-line tool is appropriate for a particular subtask in a WSH script, you have to try it before you decide. After you do, you'll discover that command-line tools are often the best tools for the job.