Previous Section Table of Contents Next Section

Notepad and Script Editors

When it comes time to write your scripts, you'll probably take the path of many administrators before you and start with Notepad. It's free, easy to use, and did I mention that it's free?! But you'll probably come to a point where you realize that Notepad is making you work too hard, and it'll be time to look at some professional alternatives.

Bare Bones: Notepad

Notepad, shown in Figure 2.9, is a basic text editor that makes a passable script editor. The biggest problem with Notepad that you'll notice right away is a lack of line numbering. When you get a VBScript error, it'll refer to a specific line number. Notepad does have a "Go to line number" feature that lets you type in the offending line number and jump straight to it, but it isn't as satisfying as if Notepad displayed a line number on every line of text.

Figure 2.9. Notepad as a script editor

graphics/02fig09.gif

Notepad also lacks any kind of color-coding, which can make scripting much easier, especially for long scripts.

A Step Up: Programmer's File Editor

Programmer's File Editor, or PFE, is a decent step up from Notepad. As shown in Figure 2.10, PFE can be configured to show line numbers on each line, making it easy to zip straight to the line of code that's causing errors.

Figure 2.10. Programmer's File Editor

graphics/02fig10.jpg

PFE doesn't include any VBScript-specific functionality, however, such as color-coding of comment lines, strings, commands, and so forth. It also doesn't provide any kind of debugging integration, which is a nice thing to have for longer, more complex scripts.

PFE is a free tool, although it's no longer under development for new versions. You can download the latest version, 1.01, from www.lancs.ac.uk/people/cpaap/pfe. It's compatible with all 32-bit Windows platforms, and there's even a version for Windows 3.1.

Script-Specific: VBScript Editors

I have three VBScript-specific editors that I like to use. The first is Adersoft's VbsEdit (www.adersoft.com), shown in Figure 2.11. VbsEdit is currently in version 2.0 and costs $30 for a single-computer license. It provides a number of higher-end features, including:

  • Color-coding of syntax, meaning comment lines, commands, and other types of script will show up in different colors.

  • Line numbering.

  • Drag-and-drop editing, much like Microsoft Word.

  • Auto-capitalization of VBScript commands. This doesn't improve your scripts, but it does make them nicer to read.

Figure 2.11. VsbEdit

graphics/02fig11.jpg

VbsEdit also includes a degree of IntelliSense-like functionality. For example, when working with objects, you can type the object's name and a period, and VbsEdit will display a list of properties and methods for that object. I haven't discussed objects in VBScript yet, but trust me when I say that this is a handy feature to have! (I'll get to objects in Chapter 5.)

Finally, VbsEdit has a built-in script debugger. This handy feature lets you run scripts one line at a time, checking variable values and seeing what's going on "under the hood." This is a great way to quickly debug scripts. VbsEdit even allows you to hover your mouse over a variable while the script is running, and it will pop up the value of that variable in a Tooltip. It's a great way to see what your script is doing as you try to track down bugs. Figure 2.12 shows VbsEdit's debugger.

Figure 2.12. VbsEdit's debugger

graphics/02fig12.gif

My biggest complaint with VbsEdit-and it's a minor one-is that it doesn't include IntelliSense-like features for normal VBScript commands (you'll see those in PrimalScript, which I'll discuss in a bit). Also, VbsEdit uses its own script debugger, rather than integrating the Microsoft Script Debugger (more on that later in this chapter, too).

My next editing tool is Scribbler 2000 from Creamsoft (www.creamsoft.com). Shown in Figure 2.13, Scribbler is a solid VBScript editing tool with color-coding, drag-and-drop editing, built-in debugging, and more. Unfortunately, it's geared primarily for Web page scripting, and I find it a bit cumbersome to use in regular administrative scripts. If you plan to work with Web pages, though, you won't find a much better script editor, and Scribbler only costs $35. You can download a free evaluation from the company's Web site.

Figure 2.13. Scribbler 2000

graphics/02fig13.jpg

The "big gun" of VBScript editing is PrimalScript 2.2, which costs a hefty $149 for a single-computer license (www.sapien.com/products.htm). PrimalScript, shown in Figure 2.14, offers the usual VBScript editor frills, like color-coding, line numbering, and so forth. However, as shown in Figure 2.15, PrimalScript offers a true VBScript-specific clone of Microsoft's IntelliSense technology from Visual Studio. Notice in Figure 2.15 that there's a Tooltip displaying the proper syntax for the DateAdd statement I'm typing. This handy pop-up saves you from constant round-trips to the VBScript documentation, serving as a quick reminder of which parameters come in which order. You also get pop-up lists of object properties and methods, as in VbsEdit, automatic capitalization for prettier scripts, and so forth.

Figure 2.14. PrimalScript

graphics/02fig14.jpg

Figure 2.15. PrimalScript's IntelliSense-like syntax help

graphics/02fig15.jpg

Finally, PrimalScript integrates the Microsoft Script Debugger, shown in Figure 2.16. This handy tool, which I'll cover in more detail later in this chapter, lets you step through script one line at a time, making it easier to pinpoint errors and correct coding issues.

Figure 2.16. PrimalScript launches the Microsoft Script Debugger with your script ready to go.

graphics/02fig16.gif

NOTE

PrimalScript also supports WinBatch, Ruby, ASP, HTML, PHP, JSP, and a bunch of other scripting languages-it's not VBScript only.


To my knowledge, PrimalScript is also the only VBScript editor that integrates script signing, which is a key function of secure scripting environments. By digitally signing scripts, you can instruct your client computers to execute only your scripts, based on their signed identity. (I'll cover script signing and other security topics in Chapter 28.)

    Previous Section Table of Contents Next Section