Scripting and
Windows
A wide array of scripting
languages provide automation of different aspects
of PC use. A recent search on Google turned up
787,000 references for "Windows" and "Scripting".
The two major players in this arena are Microsoft's
VBScript and Wilson WindowWare's WinBatch.
VBScript is supplied free
by Microsoft. It includes COM libraries for manipulating
the Windows shell, Microsoft network clients,
files, OLE, keystrokes, and regular expressions.
(www.microsoft.com/scripting).
VBScript lacks some object collection capabilities,
GoSub, GoTo, file read/write, date and time functions,
some DDE capabilities, some error handling, Clipboard
access, editable dialog boxes, graphical dialogs,
external dialog manipulation, Novell Netware administration,
and peripheral port manipulation. Technical support
is provides on a fee basis.
WinBatch includes its WIL,
Windows Interface Language, for simple scripting.
It has subroutines, user defined functions, arrays,
variable scoping, editable dialogs, graphics in
dialogs, a keystroke and mouse recorder, and 30
special purpose libraries for Microsoft network
administration, Netware administration, peripheral
automation, legacy software manipulation, and
more. WinBatch lacks regular expressions. The
purchase of WinBatch entitles the purchaser to
technical support by phone, fax and email. A newsgroup
is sponsored by Wilson WindowWare. WinBatch includes
reference manuals. (link
to WIL PDF Reference Manual)
All scripting tools share
core attributes. First, they use plain text for
the script. This script is a list of instructions
to be read, parsed, and acted upon by computer
software called an interpreter. In the case of
WinBatch and VBScript, both can call Windows API's,
but other scripting tools generally cannot. WinBatch
supports COM automation to automate .NET server,
XP Professional, and Windows 2000 systems management
to manage networks, provide realtime health monitoring
and Windows .NET Enterprise Server management.
Since compilation is not
required, script development is usually faster
than creating a software program in a compiled
language like C. A script can be processed by
the interpreter completely in interactive mode.
There is no edit-compile-test-debug cycle. A scripting
language can test for conditions while it runs.
Then it can respond to events as it runs.
Most scripting languages
work in a similar way. The differences between
them usually lie in the provision of special purpose
function libraries. PERL includes libraries of
functions optimized for processing text data.
VB Script provides access to COM objects with
a syntax to match. WinBatch provides Windows desktop
automation tools including keystroke and mouse
sending, Clipboard manipulation, disk and file
manipulation, Registry manipulation, Microsoft
network administration, Netware administration,
and over 30 additional special purpose function
libraries. The WinBatch syntax is oriented towards
sequential processing of tasks. It is not driven
by events.
All these scripting tools
have their advantages and disadvantages. All are
available on the Web as free downloads. All can
be tried at no cost before being put into production
use.
Example of WIL
Scripting with WinBatch
This example compares two files. It has all the
syntax absolutely needed to use WinBatch. The
wealth of examples in help files provide ready-made
code examples for rapid learning in actual use.
; Semicolons start comments ignored
by the script processor.
a = FileCompare("myFileA.txt", "myFileB.txt")
; Use a variable named "a". It will
accept any type of data automatically.
; If the compare worked, a 1 is returned
in "a". Otherwise a 0 is returned in "a".
if a == 0
; Two = = are used to test for equality.
Other tests use < > = ! alone or in
combination. For more on operators, look.
Message("File Compare Results", "The files
are identical in size and byte content.")
; Message boxes, all automatic,
display data to users of your scripts.
else
Message("File Compare Results", "The files
are different.")
EndIf
:cancel
; This label, :cancel, will become the destination
of Cancel buttons in dialogs. It is usually
put at the end of a script. WinBatch scripts
automatically quit. Scripts will also terminate
if they encounter an "Exit" function.
The code above is almost all you have to know
in order to use WinBatch.
|
|
|
|
Final WIL
Scripting Tips
To concatenate strings use StrCat("stringa","stringb",myVariable,
myConstant).
Use constants (no quotes around these) for string
display. Insert these in any string: @TAB, @LF,
@CRLF.
Statements must be 256 characters, or less, in
length. There is no practical limit on the size
of variables.
There is no line continuation capability.
Variables are defined when used. To dimension
a variable, simply use it. A function, IsDefined(myVarName),
can test the validity of a variable.
Negation is indicated by a !.
Example: If !IsDefined(myVar) then... or If !FileExist("myFile.exe")
Then
We recommend this approach to writing WIL scripts:
1. Use our WinBatch Studio editor. It is a complete
WIL scripting environment. Find it in the WinBatch
section of the Start menu. To use it, simply start
and save an empty file using a WBT extension.
This identifies the file. It also starts color
syntax verification. The script can run from the
editor menus or toolbar.
2. To get access to help files, simply activate
the context menu in WinBatch Studio by clicking
the right mouse button anywhere in a file.
3. To continue with the example above, find FileCompare()
on the context menu following the "Insert WIL
Function
" menu item. Click on the function.
It is pasted into your script. Also, a help page
on FileCompare will appear with a sample script.
The help page will link you to other File functions.
That is about all you need to know to use WIL
in WinBatch. Start a script, look for a function,
copy an example into a script, and modify it for
your needs.
Some case study topics:
Silent
software installations on NT workstations
Active
Server Installation Script
Manipulating
Windows Task Scheduler
Get
historical weather information from Web
Radio
Shack multimeter scripting project
Enumerating
computers in a given Win2k AD Domain
Bypassing
Novell's Logon GUI Dialog?
Test
Network Drive Mappings
Microsoft
Client Workstation Administration
Large Collection
of Case Studies and Practical Examples.
Operators
These are much like those used in other languages:
WinBatch logical operators include == for identity
of two values, > < <= >= <>
! greater than, less than, less than or equal,
greater than or equal, not equal, not equal (synonym).
! is also the logical not.
WinBatch arithmetic operators include * / **
mod + - multiply, divide, exponentiate, modulo,
add, subtract.
For bitwise operators and other types, look for
Operators in Windows Interface Language.hlp.
Syntax in WIL, WindowWare's
Windows Interface Language
Scripts are lists of instructions of fewer than
256 characters. Instructions are processed in
order, as you expect in a "batch" language. This
is useful for automating an ordered, or timed,
sequence of operations. WIL functions can assist
in sequenced processing. RunWait() waits for an
application to close before processing the next
instruction. (Note: single WIL functions like
RunWait() can require substantial programming
in other languages.)
A statement on a line with a comment:
myVar = FileCompare("file1", file2") ; Comments
follow semicolons.
String concatenation is accomplished with StrCat("string",
variable, variable)
WIL offers sub routines, user defined functions,
and arrays. WIL sends keystrokes and menu items
to software applications. It also includes DDE
fu; functions, DLL call functions, and OLE automation
of COM objects with ObjectOpen and other functions.
Programming tools include the WinBatch Studio Editor/Debugger,
a Dialog Editor, and a Window manipulation robot (Roboscripter).
Over 30 extender libraries supply advanced, or
special purpose, functions. They implement networking,
connect with peripherals, deal with Internet access,
connect with SQL databases using ODBC. For the
current list click here: .
For a list together with extender content, click
here: 
The tutorial is located in the Windows Interface
Language.hlp file. This can be downloaded in PDF
format. 
|