Development Tips
As you develop WSH scripts, you'll quickly discover that you'll need more than just ephemeral knowledge of the commands and references to complete most tasks. Windows is a complex system, and your scripts don't exist in a vacuum. The rest of the solutions and examples in this chapter will help you write scripts that operate in the broader context of the fully functioning Windows XP environment.
Deciphering Script Errors
One of the general disadvantages of scripts is that they are typically created with a plain-text editor, rather than a rich debugging environment used with many more sophisticated programming languages (see Section 9.3.2 later in this chapter). Because Notepad isn't specifically designed to understand VBScript, it can't offer any assistance with syntax (grammar) or errors while you're editing. Therefore, you must wait until you run the script to see if there are any problems. If WSH encounters an error, it will display a message similar to that shown in Figure 9-2.
Figure 9-2. The Windows Script Host displays a message like this whenever it encounters an error
Surprisingly, this sparse message box actually provides enough information to resolve most problems. Naturally, the first field, Script, shows the script filename in which the error occurred. This is especially useful if the script was run from a scheduled task or from your Startup folder, and ...
Get Windows XP Annoyances for Geeks, 2nd Edition 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.