In-Depth

Write the Perfect Script

Need to go deep and seize control of your Windows systems? One of these tools can help you perfect the art of scripting.

At some point in your career, you'll grow impatient with fancy graphic interfaces and yearn to take more control of your systems. You've heard how scripts can unlock your computer's secrets. So you open Notepad and type—Wscript.Echo "Hello World!" Double-click the file in Explorer, and you're rewarded with the popup in Figure 1. Suddenly, you're a scripter.

Before you know it, you're scouring newsgroups for sample scripts and searching for help on syntax and functions. You're subscribing to RSS feeds for every scripting Web site and blog you can find. Most importantly, you realize Notepad is a pathetic tool for doing serious scripts.

If you tend to keep your scripts short and you don't want to spend much money, you might be satisfied with a simple script editor like Notepad (see sidebar, "Simple Script Editors"). To be truly productive writing large or complex scripts, though, you'll need an editor that provides a complete scripting environment. You'll pay a few extra bucks, but the savings in time and frustration and the level of control you'll have over your Windows systems make this an excellent investment. An integrated scripting environment provides an array of features designed to simplify the development and testing administrative scripts.

Figure 1.  Just by typing a simple message into Notepad, you've entered the world of scripting.
Figure 1. Just by typing a simple message into Notepad, you've entered the world of scripting.

For this roundup, we considered four of the leading scripting environments:

  • AdminScriptEditor 2.2
  • OnScript 1.1
  • PrimalScript 4.0
  • VbsEdit/JsEdit 2.0

The scripting environments included in this roundup all support one or both of the native Windows script interpreters—VBScript and JScript. This means we did not include tools like Komodo from ActiveState. If you write scripts using Perl, Python, PHP, Ruby or Tcl, you might want to consider Komodo as well.

In This Roundup
Click image to view larger version.

Code Warrior
A script editor's features generally fall into four discrete categories—editing aids, coding aids, debugging aids and distribution aids. When it comes to comparing usability, a simple list of features can't tell the whole story, though. Here are a few examples of how these four compare:

  • All of the editors let you comment on blocks of text with a toolbar button, but only AdminScriptEditor (ASE) puts this feature in a properties menu.
  • AdminScriptEditor and PrimalScript let you use "code folding," a technique for collapsing regions of code so you can focus on one section at a time. OnScript takes a different approach by offering an Outliner that displays the names of functions and subroutines, but not arbitrary regions of code.
  • AdminScriptEditor and PrimalScript Pro Professional edition have wizards to simplify creating Active Directory Services Interface (ADSI) code.
  • PrimalScript Pro has a database browser to generate code for accessing a database and AdminScriptEditor has a feature for generating Access and SQL Server database connection code.
  • All the editors let you edit multiple files at once, but only AdminScriptEditor, PrimalScript and OnScript support split-screen editing of the same file. PrimalScript and OnScript support a single split and ASE supports a four-way split.
  • Code re-usability is a great convenience. OnScript, AdminScriptEditor and PrimalScript let you browse through a library of code snippets and inject them into the current script. ASE provides extensible wizards for injecting code to access Registry keys, Active Directory objects and so on. PrimalScript Professional can compare two files and show you the differences, a nifty way to find glitches in similar scripts.
  • If you share responsibility for updating scripts, you'll like the way PrimalScript integrates into SourceSafe, Microsoft's version control developer utility, so you can enforce version control.
  • AdminScriptEditor can save scripts in HTML format so you can post the code on a Web site while retaining syntax coloring. ASE also lets you constrain the editor window to a given number of columns, which helps avoid word wraps when cutting and pasting lines.
  • PrimalScript can record, play and store macros, as well as assign macros to specific keys.

The list of small but significant differences goes on and on. Keep in mind that this is a highly competitive market. If a product lacks a particular feature, you can bet it will be included in the next version. Here's a more detailed look at some of the functional categories you'll find in all four of the scripting environments reviewed here.

Simple Script Editors
Even serious scripters should pay attention to these simple script editors. They provide a quick and easy environment for making changes.

Notepad2
This freeware Notepad replacement is small, fast, highly useful and comes with its own source code if you want to do any customization. The product is free, but donations to Amnesty International are requested.

GVIM (Graphical VI iMproved)
Even if you've never used VI, you'll appreciate this tool's amazing range of features and speed. Although the GVIM menus expose a wide variety of features, the true power comes from a command-line interface that accepts a dizzying array of commands. You can extend those with a phalanx of add-ons contributed by a fanatical band of “vimmers.” GVIM is free, but if you want to support development, a sponsorship costs 10 Euros. Donations to needy children in Uganda are also requested.

Crimson Editor
If you want lots of features but prefer the functionality of a GUI-based editor, you'll like Crimson Editor. Crimson Editor sports a handsome and useful editing window, extensive language support, a tabbed interface for editing multiple files, fast and simple macro recording, a fantastic array of text display tools and hotkey support for every feature. Crimson Editor is freeware with a suggested sponsorship donation of $10 a year for personal use and $30 a year for professional use.

— B.B.

Debugging Support
As you write longer and more complex scripts, it will be harder to troubleshoot errors. At some point, you'll want a debugger to help you figure out why a particular script won't run correctly.

AdminScriptEditor and OnScript use Microsoft's Script Debugger, which lets you set breakpoints and step through the code one line at a time. OnScript opens the debugger, then jumps right to the offending line that's causing the error.

PrimalScript and VbsEdit have integrated debuggers (see Figure 2) that make troubleshooting a more seamless experience. Both editors display the values assigned to variables during debugging, but only PrimalScript lets you view the variable values while you step through the code.

Figure 2. PrimalScript's integrated debugger
Figure 2. PrimalScript's integrated debugger streamlines the process. VbsEdit also has an integrated debugging tool. (Click image to view larger version.)

Language Support
As the names imply, Adersoft's VbsEdit and JsEdit are limited to editing files in their respective languages. The remaining editors support a variety of file types, including XML, CSS, INI and batch files.

PrimalScript has the broadest language support. In addition to the languages mentioned above, it supports Macromedia Flash ActionScript, an array of Web files and many programming languages and frameworks like .NET.

OnScript supports HTA files, which is a common way to put a graphical interface on a script. It also supports Perlscript and Pythonscript.

AdminScriptEditor focuses on VB-Script, KiXtart and AutoIT, but plans to support HTML and ASP files (including HTA) in its next major release.

KixTart is a scripting language developed by Ruud van Velsen that has wide community support. (In fact, AdminScript-Editor began life as a KiXtart editor.) AutoIT is a specialized language designed to simplify GUI-based programming for large numbers of machines.

Context-Sensitive Help
All of these scripting environments have online help, except for VbsEdit. Where you'll really need the help is figuring out how to use the functions in a particular scripting language, how to use the properties and methods in automation objects accessed by a script, and how to wring the most functionality out of major scripting interfaces like ADSI and Windows Management Instrumentation (WMI). This is where you really get your money's worth from an integrated scripting environment.

For example, all of the editors have integrated help for VBScript. PrimalScript lets you search an "Information Nexus" for help on a particular function. OnScript and VbsEdit have the Microsoft VBScript 5.6 help file integrated into their editor, so all you need to do is press F1 to open the Help file. AdminScriptEditor lets you right-click a VBScript function and choose a help feature, which opens a window displaying the syntax and giving examples (see Figure 3).

Figure 3. You can get to special help for VBScript functions from the property menu in AdminScriptEditor.
Figure 3. You can get to special help for VBScript functions from the property menu in AdminScriptEditor. (Click image to view larger version.)

Each of the editors also has language-sensitive, popup-syntax help (see Figure 4). This helps remind you of a function's required elements. OnScript doesn't fully expand the syntax of a selected class, which limits the usefulness of its popup help. VbsEdit's help items provide the most information, including not only the syntax, but the purpose of the object class as well.

Figure 4. The popup syntax help in VbsEdit.
Figure 4. The popup syntax help in VbsEdit. A similar feature is available in all the scripting environments included in this roundup. (Click image to view larger version.)

COM Code Completion
There's one feature that's even more useful than syntax help—COM code completion. This is patterned after a Microsoft trademarked term called IntelliSense, and comes into play when you create a COM object, then use it later in the script. The editor displays a menu of available methods and properties for that particular COM object and lets you complete the code with a selection from the menu.

Because IntelliSense is trademarked, AdminScriptEditor calls this feature ScriptSense. PrimalScript calls it PrimalSense, and OnScript simply calls it COM code completion. VbsEdit has no documentation and therefore doesn't need to concern itself with trademark issues. Not all the COM code completion features are equal, though. Consider the following lines of VBScript code:

Dim objExcel, objWorkbook, objSheet1, objSheet2
Set objExcel = CreateObject('Excel.Application")
Set objWorkbook = objExcel.Workbooks.Add()
Set objSheet1 = objWorkbook.

When you type the period in the final line, you'd want to see a menu of available methods and properties for the Workbooks class. Only VbsEdit and PrimalScript actually provide a menu. The other scripting tools should have this feature in their next release.

Object Type Library Browsing
The real secret of power scripting is making good use of the vast array of automation objects in Windows. You can search the Platform Software Developer's Kit (SDK) to learn about these, but often the documentation doesn't include truly useful samples. And, of course, you won't learn about third-party automation objects in the Platform SDK.

Three of the editors (the odd guy out is VbsEdit) have a feature that lets you browse the locally stored registered automation objects and select properties and methods from a tree. For example, let's say you're using ADSI in a script to query Active Directory and display a user's last logoff time. You know that ADSI uses the Active DS Type Library and that user attributes are stored in an object class called IadsUser. You can use a type library browser to view the properties of the IadsUser class and find the spelling and syntax for the LastLogoff property (see Figure 5).

Figure 5. The Object Type Library browsers in PrimalScript (left) and OnScript (right).
Figure 5. The Object Type Library browsers in PrimalScript (left) and OnScript (right). (Click image to view larger version.)

If you look closely, you'll see that although both editors have a tabbed window to get at the type library browser, PrimalScript is a bit harder to use because it doesn't sort the classes alphabetically and includes many classes that aren't useful for scripting. OnScript has a nifty feature that lets you insert sample code from a selected object's property listing.

Figure 6. AdminScriptEditor's Type Library Browser has a Search feature that helps you look up properties by name or partial name.
Figure 6. AdminScriptEditor's Type Library Browser has a Search feature that helps you look up properties by name or partial name. (Click image to view larger version.)

AdminScriptEditor simplifies the process even more. You can load a selected class in the viewer, then use a Search feature to find a particular property or method (see Figure 6). This search feature makes it easier to figure out which properties of a selected class might be useful in a given script.

WMI Scripting
You can't really take advantage of the power of scripting in a distributed environment until you learn how to access WMI from within your scripts. WMI has a well-deserved reputation for being difficult to master.

The Scripting Guys at Microsoft provide a ScriptoMatic utility. This HTA utility lets you select a WMI class and inject code to display the properties of the class for all instances on a target machine.

All of these editors have a similar feature. OnScript straps ScriptoMatic onto its interface and lets you insert the output code into an open file.

PrimalScript has a menu item for exploring WMI classes and injecting enumeration code. VbsScript does something similar with a toolbar menu.

Figure 7. AdminScriptEditor's WMI wizard shows the property selection option.
Figure 7. AdminScriptEditor's WMI wizard shows the property selection option. (Click image to view larger version.)

AdminScriptEditor takes WMI support to the next level. You can not only select a WMI class, you can select individual properties from within that class (see Figure 7). You can also set conditionals to limit what instances of the class will be included in the output, such as specifying a minimum freespace when listing disks. Here is a sample script inserted by the wizard:

Set wmiColl = GetObject("WinMgmts:root/cimv2")._
       ExecQuery("Select * FROM Win32_DiskDrive " & _
                            "WHERE Size > 60000000000")
For Each wmiObj In wmiColl
       WScript.Echo wmiObj.DeviceID
       WScript.Echo wmiObj.Manufacturer
       WScript.Echo wmiObj.MediaType
       WScript.Echo wmiObj.Partitions
       WScript.Echo wmiObj.Size
Next

End Line
The list of features for PrimalScript, OnScript, AdminScriptEditor and VbsEdit/JsEdit are quite similar, plus this is an extremely competitive market. So when you see a new feature in one, you can expect to see something similar in the others before long.

AdminScriptEditor has a certain elegance about how it presents its features and options, from the simplified library browsing and WMI scripting to its context-sensitive help with examples. PrimalScript is right up there as well, with a thoughtfully conceived help search, extensive language support and an integrated debugging tool.

OnScript has some handy troubleshooting and help features, including a slick outlining tool for examining scripts in process. It also integrates with Microsoft's debugging tool and brings you right to the troublesome line for correction. VbsEdit features a helpful integrated debugging tool. Both OnScript and VbsEdit integrate with the Microsoft VBScript help file as well. VbsEdit and JsEdit are limited to working in their respective languages, however, and lack context-sensitive help.

Each of the integrated scripting environments covered here have trial downloads with generous evaluation periods. Try each one for a while to see which best fits your needs before evaluating solely on budget or list of features. That's the best and most accurate way to make your evaluation. All of these are stable, solid products that deliver considerable value.

More Information

  • A complete comparison of features can be downloaded here (Excel format)
  • For a free download of AutoIT, go to: www.hiddensoft.com/autoit
  • Get more information and download the most current version of the KiXtart scripting tool at: www.kixtart.org
  • To learn more about the Komodo scripting tool from ActiveState, go to: www.activestate.com
  • Download the Microsoft Script Debugger here
  • ScrptoMatic can be found here
  • Download a copy of Notepad2 here  
  • Download a copy of GVIM here
  • Download a copy of Crimson Editor here
comments powered by Disqus

Reader Comments:

Fri, Sep 25, 2009 Itsme

Seems as though the AstroTurf here is mighty deep. I would never consider either of the two main tools, but it sure looks like a lot of the comments about PrimalScript were from some of their own people.

Sat, Jun 6, 2009 Trustin New York

Greeting. Lawyers spend a great deal of their time shoveling smoke.
I am from Paraguay and also now teach English, give true I wrote the following sentence: "World allergy organization wao is the leading source of allergy information antagonists with anti allergic and anti inflammatory properties has caused.Health benefits of flavonoids, a group of plant pigments with potent have anti cancer, anti inflammatory, anti allergic effects, and anti asthma effects."

With love :D, Margarita.

Mon, Mar 30, 2009 Anonymous Anonymous

Good Day. A hobby a day keeps the doldrums away.
I am from Somalia and , too, and now am writing in English, please tell me right I wrote the following sentence:

Fri, Feb 13, 2009 Anonymous Anonymous

Hi all. Read over your compositions, and wherever you meet with a passage which you think is particularly fine, strike it out.
I am from Denmark and too poorly know English, please tell me right I wrote the following sentence:

Sun, Apr 30, 2006 Anonymous Anonymous

All said and done, nothing to beat Automator on Mac OS X because it's "hey its GUI scripting". When will MS develop such a software for Windows? Does any 3rd party solution exist?

Sun, Aug 21, 2005 Jason San Diego

I don't think cost is that much of a factor. Within reason of course. If you spend half of your time scripting in a day, and a tool saves you, say ONLY an hour a day. You save about 20 hours a month. Give or take. Let's make that 10. Now multiply by your hourly salary.
Even with the most expensive of the bunch you have your investment back in two months.
That is pretty good ROI.
The gas analogy doesn't work BTW. Gas you by constantly to fill up. A good editor you buy once.
An upgrade every year or so is usally not that bad.

Sat, Aug 20, 2005 Harold Chicago

I firmly believe that trying both is the way to go. And, just as firmly, feel that ASE will be the editor of choise. But, features aside, is it possible that no one cares about cost when buying editors? People will drive miles to save a penny on a gallon of gas and then pay twice as much for software. Even if they were close in features, price would then be the distinguishing factor. Even when purchasing for your company the savings should be considered and used to 'pat yourself on the back'.

Thu, Aug 18, 2005 Anonymous Anonymous

"Is it true that PrimalScript doesn't even support word wrapping? Wow! Even notepad does that." Seriously? You want word wrapping in a script editor? I'd never even conceived of that. VBScript is sensitive to line-wrapping and automated wrapping would drive me nuts. Just more evidence, I guess, that folks have very different priorities in a script editor.

Thu, Aug 11, 2005 Anonymous Anonymous

The info given here looked really familiar until I realized that this is the same information that Chad Marshall and Don Jones covered at TechMentor back in April. When I read articles I'm actually reading them looking for some NEW information, this just seems like the exact same thing I've already heard only copied and printed rather than presented. How about some NEW IDEAS?

Mon, Aug 8, 2005 Jason Memphis, TN

I use a licensed version of UltraEdit 11 and a licensed version of Komodo Professional 3.1.

Both IDEs are great and which one I use depends on the specific task I want to perform.

My suggestion is to talk to people whose opinions you know and know how to weigh. Find out what they like and why. Then try it for yourself.

Only you know what features are important to you so only through a dialogue with someone who understands a particular tool can you decide if it is worth trying or not.

Or if you have the time, try them all. Like has been said repeatedly in these comments.

Mon, Aug 8, 2005 Jared Dallas

jEdit is free. I'm not advertising here (it's free, after all.) I just find it hard to believe anybody would pay for a scripting editor.

Sat, Aug 6, 2005 Mike Mammoth Lakes

Doubt that you have seen PrimalScript 4.0. It is in beta and Bill Broswell had a copy of it.
I have seen it and there is no doubt that PrimalScript is a clear winner

Fri, Aug 5, 2005 Khalifa Seattle

Indeed fascinating. I have been at the wheel for over a decade and have employed all three. One must test the trial donwloads to reach a clear conclusion. ASE is clearly the best editor for our firm.

Thu, Aug 4, 2005 Anonymous Anonymous

I have to agree with the post above, except for how long you try it out. All these products have a 30 - 45 day trial. Use these days.
The price differences may seem significant too, but when it comes down to what makes you productive you recover that money quickly.
I find it also of interest if and how quickly you can get in touch with a vendor. Shoot them a question and see if and when you get a response.

Wed, Aug 3, 2005 Anonymous Anonymous

This is quite fascinating...

It's obvious from this reading that everyone has a clear favorite. It's equally clear that all of these editors offer features that the others do not. The problem is that a proponent of "Editor A" only knows the features of "Editor A", and he may also know which features of "Editor A" do not exist in "Editor B". BUT, since he does not know the features in "Editor B" that do not exist in "Editor A" he will blindly state that "Editor A" is the clear winner.

Take it from someone who has done a lot of scripting with several different editors. If you haven't already made up your mind (and it's clear that everyone posting above already has), then you owe it to yourself to download these different editors and give them each a 10-15 minute workout. Find out which feels best to you and buy it.

No single editor is going to provide all the features you're looking for, so find the one that will make you the most productive. Ignore all the fan boys and decide for yourself.

Wed, Aug 3, 2005 Anonymous Anonymous

For those few of you that might not be aware, Cain's title should be "Sapien Marketing Dept. Lackey". Is it true that PrimalScript doesn't even support word wrapping? Wow! Even notepad does that.

Wed, Aug 3, 2005 Cain Anonymous

Debuggers, Debuggers, Debuggers...When it comes to these little guys, all the upper scale IDE's claim they have an integrated debugger. Let's face it, if you download the Microsoft Debugger, and install it in the IDE, it is integrated. Here is the big difference folks......PrimalScript Pro 4.0 has it's very own, built by the engineers, built in debugger, and it's called PrimalScope. You do not have to download anything, it is built in. And it was designed by the engineers at SAPIEN, because for the most part, the Microsoft debugger, does not always work properly. So SAPIEN has really done a great job of setting themselves apart from the pack, by having a real "INTEGRATED" debugger. Bill fails to mention this in his article, and actually makes it sound like the PrimalScript debugger is no different than anyone elses....Nothing could be further from the truth. Bill, please note, integrated is not the same as built in...not even close.

Wed, Aug 3, 2005 Robert Anonymous

Time changes your opinion too. I started with VBSEdit and through PrimalScript was WAY too complicated. But when I got more experienced and tried PrimalScript again I started to like some of the more complicated features now that I knew what they were for ;). I like the article simply because it calls attention to products like this - I'd never buy something without trying it for myself anyway.

Wed, Aug 3, 2005 Anonymous Anonymous

People sure do love their editors! An entire mag could be devoted to every feature and it still would not satisfy everyone. I for one could care less about a COM browser, but I'm sure someone will say it is the most important thing there is. I think the article does a good job of providing an overview of available features (some I did not know about) and what editors to check out. Just my $.02.

Wed, Aug 3, 2005 Jim Anonymous

The only value of this article is in the last paragraph: Download all the trials and try them for yourself. An editor is a very personal choice and needs to fit the way YOU work and provide the features YOU need at a price YOU can afford and nobody else can tell you what that is. The rest of the article glosses over too many important issues (Primalscript's "deeper" implementation of "intellisense" is important for me, but there's no mention of this detail) and contradicts itself too much.

Wed, Aug 3, 2005 Anonymous Anonymous

PrimalScript 4 isn't vaporware, you idiot. It's shipping this month and there's ample information available about it and a very active beta program.

Wed, Aug 3, 2005 Anonymous Anonymous

Primal Script 4 is vapor-ware! Why not compare it to ASE 3.0 and OnScript 2.0?

Wed, Aug 3, 2005 Mike Anonymous

"I spent a lot of time to find this application jewel and have never looked to another IDE since." - A common view, people simply like what they know and comparing unfamiliar to the familiar, most will favor the one they know. To the defense of ASE, I own both Primal and ASE and find ASE to be "unquestionably" the better of the two. The review could obviously not contain a complete feature comparison- even if it did, one implementation may be better than the other. I used Primal for years before switching to ASE and I find it much easier to use as a Windows Admin. And for arguments sake 30mb is with the .net framework which you don't have to download.

Tue, Aug 2, 2005 Brad Anonymous

I'd really like to understand the writer's "objective" review of the high-end editors described in this article. The comments contained in the article simply do not coincide with the ratings and scoring depicted on the overall rating table. First of all, when it comes to interface PrimalScript is the winner hands down. It's skinnable interface and professionally organized toolset are simply the best you will find. When it comes to features, PrimalScript offers the ability to create workspaces. Workspaces are ideal if you have several files all tied to a specific task or project. Assigning files to a workspace make it easy when you need to use all of these files in the future. Simply open your workspace and they're all there in one neat, organized, alphabetically sorted package. Secondly, PrimalScript offers Global Find & Replace and Find in Files which the highest "feature" ranked editor do not. PrimalScript offers an integrated FTP Explorer. PrimalScript simply offers so much more. And the installation file for PrimalScript is under 4MB. ASE comes in at around 30MB. I am not affiliated with Sapien or PrimalScript in any way, shape or form. I simply use their IDE because it is unquestionably the best there is. I spent a lot of time to find this application jewel and have never looked to another IDE since. Do yourself a favor. Check it out.

Tue, Aug 2, 2005 Anonymous Anonymous

A complete comparison of features can be downloaded here (Excel format)

Nope, not working.

Tue, Aug 2, 2005 Anonymous Anonymous

You gotta be kidding me. The article points out dozens more features in PrimalScript, but ASE gets top score for value adds and feature set? ASE and OnScript use the exact same debugger, but OnScript gets a point less for debugging? VBSEdit uses the same debugger in-process, and the article says its more convenient, but it gets lowest score in debugging? What a crock. So it's back to square one and downloading the trial versions and trying them all for yourself, since this article contradicts itself. Wonder if ASE paid Bill for a better score on the chart?

Add Your Comment Now:

Your Name:(optional)
Your Email:(optional)
Your Location:(optional)
Comment:
Please type the letters/numbers you see above

Redmond Tech Watch

Sign up for our newsletter.

I agree to this site's Privacy Policy.