Chapter 7. Input, Output, and Error Handling with VBScript and JScript

Displaying output to readers using WScript.Echo is useful but you often need to implement more powerful techniques in your scripts. For example, you may want to display a dialog box that allows users to make a selection, or you may want users to input a file path or directory name. In either case, you need to display a prompt that enables users to pass information to a script. This prompt can be an input box that allows users to type in text, a message box with clickable buttons, or a pop-up dialog box with clickable buttons.

As you work with input and output, you'll also need to learn error-handling techniques. If a user enters the wrong information, the script should handle the error appropriately. Some error-handling techniques are very basic, such as using control loops to ensure that users enter information. Other error-handling techniques are more advanced and usually involve the built-in error-detection capabilities of VBScript and JScript.

Input and Output Essentials

Chapter 6 discusses how you can use WScript.Arguments to access arguments passed to a script, and how you can display output with WScript.Echo. What that chapter doesn't discuss, however, is how Windows Script Host handles these standard input and output mechanisms. Basic I/O is handled through ...

Get Microsoft® PowerShell, VBScript and JScript® Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.