WSH Development
Tools
Writing WSH
scripts requires just Notepad or an other editor. But
there are other tools providing a smarter support for
script editing and testing.
Script Editors
Using
Notepad for writing scripts is a bit difficult. This
editor doesn't support language features nor does it show
line numbers to identify faulty lines. Below are a few
editors that fits better the requirements for script
development.
PrimalSCRIPT
PrimalSCRIPT
is a powerful script editor for Windows developed by
SAPIEN Technologies, Inc. If youre developing WSH
scripts or scripts for different languages, PrimalSCRIPT
might be your first choice. It provides a consistent user
interface and development environment for several
scripting languages.
PrimalSCRIPT
version 2, is perfectly suited to WSH script development.
It supports line numbering (to identify a line in an
error dialog box), a type library viewer, and much more.
You can edit .wsf files that contain several jobs or
script elements. When you select a script element, the
editor will show only the elements codethe
element definition and attributes are treated as
properties. The left pane in Figure 2-7 shows for example
the XML elements defined for the loaded .WSF file.
PrimalSCRIPT 2 also handles well-formed Extensible Markup
Language (XML) documents. Debugging is also simplified in
PrimalSCRIPT 2. The program supports in-place debugging
for WSH script files, so you can execute .js, .vbs, and .wsf
files from the editor window or pass control to the
script debugger.
Because PrimalSCRIPT 2 supports type
libraries, it can incorporate sophisticated editing
features. For example, when you enter an object keyword,
a ToolTip window shows you the definitions of the objects
methods or properties (similar to Microsoft development
environments such as Visual Basic for Applications [VBA]).
A 30-day evaluation copy of
PrimalSCRIPT 2 can be downloaded http://www.sapien.com.
Microsoft Script Editor (MSE)
Some people are using
Visual Interdev or the Microsoft Script Editor shipped
with Microsoft Office 2000. Microsoft Script Editor can
do nearly a similar job than PrimalSCRIPT, and its
free, if you have installed one of the two products
mentioned above. Before you can use this editor,
you need to do a Registry hack and you have to know how
to use the editor.
Launch your Registry
Editor (Regedit.exe) and search for the Registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\
MSE\9.0\Editors\{C76D83F8-A489-11D0-8195-00A0C91BBEE3}
\Extensions
This key contains the
settings for the files already supported. Add a
DWORD value named vbs and set its value to 28
hexadecimal. Repeat this step and add also the DWORD
values for js and wsh.
After closing Registry editor, you can
try to use Microsoft Script Editor.
- You may invoke it from an Office
application. For instance launch Microsoft Word
and use the command Microsoft Script Editor in
the menu Tools/Macro/.
- You can use a shortcut to MSE.EXE
created on the Windows Desktop or in the start
menu. The file MSE.EXE is located in the folder
Program Files\Microsoft Visual
Studio\Common\IDE\IDE98\ of your Windows drive.
But note that the folder names may depend from
your localized Windows version.
After invoking Microsoft Script Editor
you are ready to load and edit script files.
Note In Office 2003, the
editor is named MSE7.EXE and the file is located at Program
Files\Microsoft Office\OFFICE11
TIP You can use the command
View/Define Windows Layout to choose one of the
predefined editor layouts.
To load and view a script file, simply
drag it to the edit window (or use the File/Open Files
menu). The names of files already loaded are listed in
the Project Explorer window. And here a few trick you
should know:
- Select the Source tab to show the
document in Source View.
- Color coding for script elements
is shown default for .wsf files. In .js files,
just insert a line //<% in the header, iIn .vbs
files insert the line <% into the
header, to enable color coding.
- Use Save button in the
toolbar to invoke the Save As dialog box, let the
file type as HTML Files, but enter the file name
including the extension (like .vbs, .js or .wsf).
If the file name includes an extension different
form .htm or .html, the editor saves the code
window without adding a HTML-tag structure.
Clicking on a line may identify a line
number. Then the line number is shown in the status bar.
You can use the File/File New menu or you can press Ctrl+Shift+N
to invoke the New File dialog box window. (This dialog
box contains also two pages allowing you to load existing
and recent files.) Within the New property page select a
template file and click Open. The editor creates a file
using the template. Note that MSE doesn't recognize all
objects (for highlighting etc.). Further details may be
obtained from my Microsoft Windows Script Host 2.0
Developer's Guide (Microsoft Press USA). See also the
knowledge base article http://support.microsoft.com/support/kb/articles/Q249/0/24.asp for further details.
Other Script
Editors
A neat Freeware editor that supports
syntax highlighting for VBScript files, Bookmarks, Find/Replace
and more is offered by Koan s.a.s, a small company
located in Italy. The file may be downloaded from www.koala.it/Eng/script.htm. Beside its easy to use approach the most
interesting fact is that the program comes as a
standalone file of 400 K. So there is no need to install,
the editor can be used from a diskette.
EditPlus is a 32-bit text editor for
Windows, that is distributed as shareware. EditPlus is
simple to use and provides a syntax-highlighting feature
for HTML, C/C++, Perl, and Java that you extend to
support other languages. The best feature of EditPlus is
a toolbar button that enables line numbering in the
loaded text file. You can download a 30-day evaluation
copy of EditPlus from www.editplus.com.
EditPad is a small replacement for
Notepad that you can use to edit text files in different
formats. EditPad supports line numbering from Version 4.4.1,
so EditPad can be a useful addition to Windows. You can
download EditPad at no charge from www.jgsoft.com.
UltraEdit-32 is a powerful editor for
Windows 95, Windows 98, Windows NT, and Windows 2000 that
is available as shareware. The program supports the
editing of text files with different filename extensions
(.bat, .ini, .html, and more) and offers several features
for script editing, such as color highlighting of
keywords. In the code window, you can activate line
numbering. You can download a 45-day evaluation copy of
UltraEdit-32 from www.ultraedit.com. The site provides links for downloading
several versions of UltraEdit.
Other editors that you can use for
script editing (but which I haven't tried) include
CodeMagic, TextPad,
and NoteTab. TextPad and NoteTab are
shareware editors. NoteTab also comes in a Light version
that's freeware. Neither editor supports text color
highlighting. You can download TextPad from www.textpad.com
and NoteTab from www.notetab.com.
Debugging
Script debugging is
supported from Microsoft's script debugger. This debugger
is shipped as an optional component with Microsoft
Windows 2000. The debugger may be also downloaded for
free from Microsoft's scripting web site http://msdn.microsoft.com/scripting. Note that there are two versions, one
for Microsoft Windows 9x and one for Microsoft Windows NT.
The scripting web site contains a few remarks about these
two versions and about requirements.
If Microsoft Office or
Visual Interdev is installed, I recommend to uninstall
Microsoft Script Editor. MSE contains its own script
debugger that will be invoked automatically, if an error
is detected or if a debuggin switch (//X or //D) is
recognized. Chapter 2 of my WSH Tutorial (downloadable
for free as WSH Tutorial sneak preview) contains a more
details about debugging.
Ernest Edwards wrote a
debugging COM object to avoid testing scripts with
msgboxes. The COM object directs its output to a debug
viewer (still available for free from www.sysinternals.com). Download the debugger helper (zip-archive) and enjoy.
WSH Trust Policy
Changer
Windows XP
supports a Trust Policy that allows disabeling WSH script
execution. The small HTA-tool TrustPolicy.hta provides a user interface (still
in German) with the necessary options to set the trust
policy.
Further Information
A more
detailled discussion of script development techniques,
debugging and tools may be obtained from my titles:
- German:
Inside Microsoft Windows Script Host, Microsoft
Press Germany, 2000, 850 pages.
- English:
Microsoft Windows Script Host 2.0 Developer's
Guide, Microsoft Press USA, 2000, 527 pages.
Copyright
(c) by Günter Born
All Rights Reserved
|