1. Understanding JavaScript and VBScript Compilers
Generally,
you aren't going to find a JavaScript or a VBScript compiler that works
at the command line. The problem is that you need to have the support
of the Windows Scripting Host (WSH) at the command line and WSH only
provides an interpreted environment. Consequently, what you'll find is a
vast array of JavaScript and VBScript editors, some of which are
extremely complex and provide just about anything you could ask for,
except WSH support. For example, the C-Point Antechinus JavaScript
Editor (http://www.c-point.com/javascript_editor.php) shown in Figure 1
provides all of the functionality that you would expect from a
full-fledged programming language at a fraction of the cost.
Unfortunately, while this editor provides everything you need, including
IntelliSense support, to build a Web application, it won't help you
create a JavaScript application that relies on WSH. Yes, it will help
you write the code, but you can't compile it.
An important issue to
remember is that any time you see HTML Application (HTA), what you're
really talking about is a Web application of some sort. Yes, you can
create stand-alone HTA versions for the local machine with the right
editor, but an HTA can't rely on the functionality that WSH provides,
which means that you'll lose a lot of functionality. The best place to
look for tools that will work at the command line is on the Microsoft
site at http://www.microsoft.com/technet/scriptcenter/createit.mspx. Another great place to look is the Asp4Hs: Add-On's: ActiveScripts / WSH Scripts Web site at http://www.wilk4.com/asp4hs/list5.htm.
Fortunately, you can find editors that make your task significantly easier. For example, the AdminScriptEditor described at http://www.adminscripteditor.com/editor/
provides you with a number of features that make working with WSH
easier. For example, you can use it to create scripts that use Windows
Management Instrumentation (WMI). This Windows feature provides access
to various Windows management functions that you can control from your
script. This particular product isn't shareware and it doesn't come with
a fully functional demonstration program. The 45-day trial version does
give you a good idea of how the product works though.
Considering the WSH Alternatives
Microsoft
created WSH many years ago. It's amazing that this interpreted
environment still meets so many needs and will continue to meet them
well into the future. However, you still need to consider what WSH
offers as part of your application-building task. At some point, you
might need to consider giving up the convenience that WSH provides and
using an entirely different environment. You can find a wealth of
third-party utilities such as OnScript (http://www.onscript.com/en/home.asp) and ExeScript (http://www.hide-folder.com/overview/hf_7.html) online. The important consideration is finding the right tool for your particular needs.
2. Editing Script Files with Script Editor 2.1
You can edit almost any kind of script using Script Editor 2.1 (http://www.brinesoft.com/ScriptEditor.asp)
from BrineSoft. You can use any
text or XML editor to work with WSF, but it's better to have an editor
specifically designed for the task.
The first time you start
Script Editor 2.1, it asks whether you want to add existing scripts to a
workspace. You can also create new workspaces as needed using the
Workspace =>
New command. Storing your scripts in workspaces makes them easier to
manage. You can separate scripts by type and purpose. Choose any
existing workspace by selecting its entry in the Workspace field.
Script Editor comes with a number of sample scripts as shown in Figure 2.
To open a package, simply click its entry in the Files tab. Opened
packages appear in red, while unopened packages appear in black. The
selected package appears in bold type to differentiate it from other
opened packages.
Notice that you can see this structure clearly in Figure 7.9. Script Editor 2.1 makes it very easy to work with the XML data structure of WSF files as shown in Figure 3.
All you need to do to work with a particular element is right-click it.
The context menu shows what you can do with that element, so you don't
have to guess about the rules. In addition, the editor automatically
creates opening and closing tags as necessary and asks questions about
the element when necessary to define it.
Debugging a script is
also easier in Script Editor 2.1 than it is in some other editors. All
you need to do is click the Run Project/Script button (the
right-pointing red arrow) on the toolbar to start the script. When
Script Editor 2.1 sees an error, it flags it and offers solutions on
fixing the problem.
You can use bookmarks
to make it easy to locate the code you want to work with. The bookmarks
stay in place between sessions, so you can set them as needed to
maintain your place in the code between sessions. The Toggle Bookmark,
Next Bookmark, and Previous Bookmark buttons on the toolbar make it easy
to move between locations quickly.
One of the features you'll like best is the ability to drag and drop statements as needed from the left pane. Figure 7.11 shows the VBScript statements, but you'll also find statements for WScript objects and WSH statements. To use any of these aids, simply drag
and drop it from the left pane to the location you want in the right
pane. Using this approach helps you create error-free code quite
quickly.
When you find that you don't
completely understand a bit of code, you can place the cursor on it and
then click the help links in the left pane as shown in Figure 4.
You'll see a copy of Help open with the appropriate help information
selected. The help information is equivalent to what Microsoft provides,
so it does provide enough information to look for further information
should the help file itself prove unhelpful.
This
is a quick overview of Script Editor 2.1. As you can see, it provides
the means to create and edit WSF scripts quickly, which means you'll
spend less time trying to figure out the WSF technology and more time
getting your work done. The free download provides a considerable array
of features, but you can also choose to purchase the product to obtain
support and updates.