Quick Start Guide
Telling it like it is...
without the techno babble.
I've been asked to explain WinBatch without using any big words or technical jargon. So. Hmmm.
WinBatch is a bunch of software that allows people to create their own software programs to do stuff on their own computers. This is done by "programming", which is, basically, sitting in front of a computer and typing in a bunch of text, called "code".
When you type this code, you use a super-duper Notepad sort of program called an editor. WinBatch includes its own editor, "WinBatch Studio", in which you type what we call "WinBatch Code". WinBatch Studio has features that colorize important words in your code, and other features that help you make your code work properly (and that's called "debugging").
WinBatch also includes a flock of other tools to help you write code. One of them, the "WinBatch Dialog Editor" lets you "draw" dialog boxes (we call them WinBatch dialogs) and writes that part of the code for you.
Also included is a "Recorder", named "RoboScripter". It watches your actions on the computer, and make a first cut at the code required to duplicate those actions.
In addition, there are some WinBatch accessories that make life in Windows generally easier, for the "WinBatch Developer", (which is YOU, once you start writing WinBatch Code). Two of the more handy ones are called "FileMenu" and "PopMenu". FileMenu allows you to hang your own stuff onto the special "context menus" that drop down when you right-click a file in Windows Explorer. PopMenu adds a small brown owl icon to the taskbar. When you click on the owl icon, you get a selection list which you can customize to launch your favorite programs or run various scripts.
As it is all quite complicated to explain without actually having your hands on it, the WinBatch people provide a free, fully functional evaluation version of the WinBatch software. You can download, install, and test it out. The software will run for about a month or so, with occasional reminders to purchase it. After a month, the purchase screens come more often and hang around longer and longer, very slowly diminishing the usefulness of the free version. Thus, if you are actually using it, the purchase solicitation screens encourage you to purchase your own copy.
In any case, working with WinBatch is about writing your own software, called "programs", "scripts", or "utilities" or "macros". The words are pretty much interchangeable, although there may be shades of differences in the meanings.
To write your own programs, you need to use the WinBatch programming language, called "WIL", short for "Windows Interface language". WIL is an easy-to-learn, but extremely powerful programming language. Most experienced programmers have no trouble at all, and novices catch on very quickly. WIL is the first programming language for an amazing number of people.
For those of you who need a few big words here, WIL is a traditional, procedural programming language, appearing to be a hybrid of GWBASIC and "C", taking, according to the WinBatch people, the best of each, giving the power of C with the ease-of-use of Basic. All the usual programming stuff is built into WIL (expressions, assignments, if statements, for loops, while loops, user defined functions and subroutines, etc., etc., etc., the list goes on and on).
For a quick look at some WinBatch code, here are a few scripts presented for your perusal. You will see a lot more code samples in our Tech Support Database.
; Comments start with semi-colons, like this ; Stereotypical Hello World program Message("Hello","World") ;Count lines in a file - one way anyway fn="C:\test\filename.txt" count=0 handle=FileOpen(fn,"READ") While @TRUE line=FileRead(handle) If line=="*EOF*" Break Else count=count+1 EndIf EndWhile FileClose(handle) Message("Lines in the file",count) ;Sum numbers 1 to 100 sum=0 For x=1 To 100 sum=sum+x Next Message("Result is",sum) ; Animation - Draws random rectangles on the screen. BoxesUp("100,100,900,900",@NORMAL) BoxCaption(1,"Random Rectangles") BoxButtonDraw(1,13,"E&xit","750,860,900,930") BoxDataTag(1,"ACORN") N=ArrDimension(7) While @TRUE For xx=0 To 6 N[xx]=Random(255+(745*(xx>2))) Next BoxColor(1,StrCat(N,',',N,',',N),0) BoxDrawRect(1,StrCat(N,',',N,',',N,',',N),2) BoxDataClear(1,"ACORN") If BoxButtonStat(1,13)==1 Then Break EndWhile BoxDestroy(1)
WIL supports a number (at least two dozen or so) add-ons that we call "Extenders". There are a bunch of free ones included with WinBatch. A handful of extenders have been made available by other people. Some free and some not, and there are a number of "private" ones made by and used only by various companies for their own internal use. For the real techies, those who have advanced programming tools like Microsoft Visual Studio, the WinBatch people also have something they call the WIL-SDK (Software Development Kit) that shows the aforementioned techies how to write their own WinBatch extenders.
If you wish, glance at the current list of extenders then return here to keep reading...
Layout of the WinBatch Website
The WinBatch website is vast, with over 10,000 web pages of various sorts, depending how you count them. However they can be navigated once you figure out the primary entry points. And they are...
- The WinBatch Home Page http://www.winbatch.com
- The WinBatch home page. From here you can usually find images or links to click on to get everywhere else. It may be how you got to this page.
- The Tech Support Database http://techsupt.winbatch.com
- A (fairly) organized, comprehensive, and searchable database consisting of thousands of previous tech support requests, case studies, code samples, and general information on WinBatch and the various WinBatch Extenders. This would probably be the first place to check when you have a question.
- Our WinBatch Support Forum http://forum.winbatch.com
- A place to post questions and get answers to whatever kind of WinBatch related topic that may occur to you. Usually fairly good answers will show up in a few hours. Hard problems may take a few days, especially on weekends and holidays.
- Our Download Area http://www.winbatch.com/download.html
- This is were you can download the fully functional evaluation copies of WinBatch and also to possibly upgrade your current version of WinBatch to the latest release.
- And more. Much more...
- By poking at some of the various links on our home page, you can easily find lots of additional information.
- The fine print
- And of course, our standard, non-inclusive disclaimer.
Downloading and Installing the Free Evaluation Copy
Let us assume that somehow you have found the WinBatch website. You have looked a handful of the various pages, and have become wildly excited at the prospect of trying out WinBatch for whatever project you are working on. What are the next steps?
First of all you need to download a copy of WinBatch and save it to someplace on your hard drive. Next you have to unzip it. You will need an unzip program from someplace. Most Windows platforms include it, and unzip programs are commonly available on the Internet. In any case unzip the downloaded zip file to an empty, temporary directory - NOT to where you want to eventually install it.
Note: You will generally need Administrator access to install WinBatch.
In some cases, you can run the setup.exe directly from the unzip program, but it is usually safer to close the unzip program, locate the directory with Windows Explorer (Not Internet Explorer) and double-click the setup.exe file that was unzipped.
This will start the setup program where you will have a chance to specify where you want it installed and to choose some other options. Almost everyone just takes the provided defaults.
This will install WinBatch, install various utilities, and add a handful of Start Menu items. Later, if you wish you can go into the Control Panel Add/Remove software applet and (gasp) uninstall WinBatch if it does not meet your needs.
Depending on various factors, you *may* need to reboot after the install to complete the installation process.
With only the usual amount of luck, WinBatch and its various utilities should be installed at this point. To test the installation, hit the START button, navigate through the "All Programs" menu and to the "WinBatch" menu. Find WinBatch.exe and click on it.
The first time you run an evaluation version of WinBatch - and at seemingly random intervals afterwards, the "purchase solicitation screen" will pop up encouraging you to purchase the product. In any case, for now, just hit the "I agree" button to proceed with the evaluation.
At that point, the "WinBatch Navigator", which is just yet another WinBatch script, pops up giving you a number of handy choices. Whenever the WinBatch program is run without parameters, it runs the WinBatch Navigator. WinBatch generally expects that you run a WBT file directly, rather than running WinBatch.exe by itself.
You can look at the WinBatch Navigator display screen and figure out what version of WinBatch you have managed to install. If you have just downloaded WinBatch, it will, presumably, be the latest version.
Assuming that you see the dialog box pop up, then WinBatch is properly installed on the system. Also note that the entire WinBatch install process is nothing more than a (rather complex) compiled WinBatch script.
Making the first couple of programs work...
Well. Now you have WinBatch installed. Now what?
Now it is time to write a few simple programs to get started. The first order of business is to find and run "WinBatch Studio". Click on the START button, go through "All Programs" to the WinBatch menu and select "WinBatch Studio". It should have a little blue owl icon next to it. That will launch WinBatch Studio.
The very first time you launch it, it may decide is has to update some registry configuration information, and will display a small note to that effect. If this happens, close WinBatch Studio and start it up again to get the best results.
Now you should be looking at the WinBatch Studio screen. Select "File - New" to open a new document window - or hit the first button on the toolbar - which is the same thing. If you hover your mouse over a toolbar button a little "tooltip" should appear telling you what the button does.
So let's type in the first program. Enter the following line into the new window you just opened.Message("Hello","World")
Now that we have the line in the window, we have to save it. Hit the "File - Save" menu item - or the third button on the button bar. The file save dialog should pop up. Select (or make a new) a directory and type in a file name. Follow the file name with a .wbt file extension. For the WinBatch file to be able to run it MUST have a .wbt extension.. For example a filename of MyFirstScript.wbt might be a good choice.
Now that it is saved, you can run it. There are several ways to do this. We'll start with the easiest. Locate the RUN button on the toolbar. The Run icon looks like a stack of papers with a blue down arrow on top. Click the RUN button and your script should run. One of three things might happen at this point...
- It runs. A small window with a title of "Hello" and text reading "World" pops up on the screen. Success!
- Some kind of Error Message pops up on the screen. This most likely means that you have some kind of typo in the line you typed. Check carefully, especially the (parenthesis) and the "quotes", fix whatever the problem is, and try again.
- Nothing happens. Nothing at all. This usually means that when you saved it, you did not type the required .wbt on the end of the filename so that it did not get saved as a genuine, bona fide WinBatch-type file. Select the "File" menu item again, and choose "Save As", and save the file again, making sure you put a .wbt on the end of the filename. Then try again.
After getting your one line "Hello World" script running, you might try changing it a little and see what happens.
In addition, you might try copying and pasting the example scripts shown up above.
You will note that WinBatch Studio colorizes important keywords in the WinBatch script. The default color of WinBatch keywords is blue. To get help on a keyword, first click it, then right-click it. A popup menu should appear. Select the "Keyword Lookup" from the popup menu. The appropriate page from the correct help file should appear on your screen.
The right-click menu in WinBatch Studio has another great feature for new users. There is a "Insert WIL Function" menu item that can insert a function directly into your script, ready for immediate customization. This can save time digging through the help files.
You will note that WinBatch function names start with a function "group", in that the functions that deal with files start with "File", such as FileCopy, FileDelete, FileMove, and functions that deal with directories (aka folders) start with "Dir", such as DirGet, DirChange, DirMake, and so on. This is handy for looking functions up in the documentation. The function you are looking for usually clusters together alphabetically with related functions (i.e. Functions of a feather flock together).
The Help Files explained.
Speaking of help files, WinBatch has a lot of them. Dozens actually. Two main ones for WinBatch itself, one or sometimes two for each extender, and a few "free-floaters" that contain interesting information but are not tied to any particular function.
The Consolidated WIL Help file acts as a single resource for many of the various help files. It combines multiple .chm files at run time, allowing them to all be consolidated into a single Help system. So, as you install some new WinBatch product ( i.e. WIL Extenders) you will see them show up in the table of contents of this help file.
This help file can be accessed from the Windows Start menu (Start | All Programs | WinBatch |ConsolidatedWIL chm ) or from WinBatch Studio's context menu by clicking the right mouse button anywhere within an open file.
The individual help files are located in the top level directory where you installed WinBatch (which, when using the defaults, is installed in "C:\Program Files (x86)\WinBatch").
The main WinBatch help files are installed when you install WinBatch. Additional help files are installed when you install additional extenders.
A few of the more important help files are:
The Consolidated WIL Help file
The primary help file, that acts as a single resource for many of the various help files.
Windows Interface Language Help file
This is where you will be spending the majority of your time. Hundreds and hundreds of functions documented. Most with an actual example you can work with. Contains the technical language definitions, tutorials, and all sorts of valuable information.
WinBatch Help file
A much smaller, but still important help file. A small handful of functions are documented here, as well as the WIL Dialog Editor, FileMenu, and PopMenu, all of which we will discuss later in this document.
Win32 Network Extender Help file
Some of the most important WinBatch extenders. These extenders are included in the main WinBatch install (while some of the other extenders must be installed separately). The functions in these extenders give you networking, security, user management, and service management control.
The Dialog Editor explained.
After you have fiddled around with simple scripts with WinBatch Studio, you may want a more attractive user interface than the built-in functions that WinBatch offers. For custom dialogs, one normally uses the Dialog Editor.
In WinBatch, dialogs are defined by setting a handful of variables, and then issuing the WinBatch Dialog statement. Although it is theoretically possible to hand-code the Dialog Definition variables, it is rough sledding, and there are only a few experts that can do it with any degree of success. This is where the Dialog Editor comes in. The Dialog Editor allows you to "draw" the dialog using the mouse and various toolbars. The Dialog Editor will then write the WinBatch code for you, which you can then copy and paste into your script, or, possibly, save to a file.
To run the Dialog Editor, all you have to do is hit the 'Dialogs' button or the 'Debug|Dialog Editor' menu in WinBatch Studio. That should start the Dialog Editor. When the Dialog Editor comes up, it will show you a gray dialog with the obligatory OK and CANCEL buttons.
You can drag these buttons around with the mouse, and can also resize the dialog with the mouse so it fits.
On the toolbar, you can hover the mouse over the various buttons and, when the tooltip appears, read what the button does. To add a new control to the dialog, click on one of the buttons, then click on your dialog approximately where you want the control to appear. Then you can resize the control and drag it to the desired spot.
To set control options, variables, colors, fonts and other features, just right-click on the control, select "Attributes" and fill in the various little tabbed dialogs as required.
To set the dialog background color, and perhaps the defaults for fonts, as well as the dialog title and the dialog name, just right-click some blank space on the dialog, and select the "Attributes" menu item there also.
Once you get the Dialog Editor running, you can select the "Help" menu from the Dialog Editor itself to learn more.
An advanced capability, "Dynamic Dialogs", gives you control over dialogs that update content while the users interact with them.
As alluded to previously, WinBatch has some two dozen odd extenders that add a great deal of functionality to the WinBatch product. Only a few of the most commonly used extenders are included in the basic WinBatch install. The other extenders, if you want them, need to be downloaded and installed separately.
The basic install procedure for these extenders is to...
- Create an empty temporary directory.
- Download extender zip file to the directory.
- Unzip zip file into same directory.
- Close unzip program.
- Using Windows Explorer, find the setup.wbt file in the directory.
- Double-click the setup.wbt file. The extender should install in a few seconds.
- Optionally delete the temporary directory.
That's it. The extender is installed and ready for use. To figure out what you have, go to the WinBatch section of your Windows Start Menu and open the 'ConsolidatedWIL chm' help file, then locate your newly added extender under the 'Contents tab',WIL Extenders. The extender help file will have a more detailed introduction to the extender and will document all the functions that you can use, complete, in most cases, with examples.
If you are a heavy extender user, and wish to keep updated on all the extenders all the time, you can download the "vCheck" utility. The vCheck utility is just a WinBatch script, which you can also examine. It downloads a special file from our website, and uses the information in the file to see how current your installed versions of the extenders are compared to the latest and greatest available. vCheck will let you update your extenders automatically, as well as install new extenders.
To use vCheck, you must first manually (using the directions given above) install both the WinInet and the Zipper extenders. The WinInet extender allows WinBatch to access web and ftp sites (our website in this case) and download both the version information file, and, if you decide to update or install an extender, the various extender zip files required. The Zipper extender allows the downloaded ZIP file to be extracted. Once these two extenders are manually installed, then vCheck can automatically download and install the remaining extenders.
vCheck, although not a true extender in its own right, is listed at the end of the WIL Extenders section of the download page. Download it and unzip it normally, then create your own home for it, perhaps a vCheck directory under C:\Program Files (x86)\WinBatch may be a good place.
Once you have the unzipped files to their desired home, just double-click the vCheck.wbt file whenever you wish to install the latest version of any of our extenders.
Handy WinBatch Accessories
In addition to WinBatch and WinBatch Studio, the install process also installs a few handy accessories to make the WinBatch developer's life a little bit easier. They are...
- PopMenu is a handy "program-sensitive" popup menu that lives by the clock on the START bar. It is a little brown owl (one of my cousins). When you click on the owl with the mouse, a menu pops up. It is pre-programmed with a number of handy menu items. You can edit the "Menu File" -- A special form of a WinBatch script file -- to add your own menu items.
Actually PopMenu supports a number of different menu files. When you click on PopMenu a two-column menu pops up. On the left-hand side is the "Global" menu that always pops up when you click on PopMenu. The menu on the right-hand side is program-sensitive in that the menu that pops up will depend on what application was active on the screen when it was clicked. So you can write menus that only appear when certain applications are running.
- FileMenu is a Windows Explorer "context menu add-on". It basically adds menu items when you right-click a file in Windows Explorer. Like PopMenu, there is both a global menu that always appears, and a file-type-specific menu that only gets added for certain file types. For instance, you can have different menus for BMP and WAV files. The scripts used when you select a menu item can obtain the names of the files highlighted or selected in Windows Explorer.
Like PopMenu, it uses the special WinBatch menu files to define the menus. You can edit and modify them to your heart's content.
- Browser is another handy but hidden utility. It lives on the "Open Other" menu item that FileMenu adds when you right-click a file in Windows Explorer.
Browser is a file viewer that can view text files in a variety of formats, as well as view any file in Hex format. It has its arcane uses.
- RoboScripter is a different sort of recorder. As opposed to keystroke/mouse recorders, RoboScripter *knows* what is going on and can write amazingly precise scripts for you.
Basically RoboScripter is a little robot that you control, telling the robot what you would like to do. RoboScripter then can perform the action and write the script at the same time. When you are finished, you can copy the recorded script to the clipboard so that you can paste it into your program in WinBatch Studio.
RoboScripter makes heavy use of the "Control Manager" extender (which in included in the basic WinBatch install). Control Manager based scripts are generally the best way to deal with most of the standard Windows Dialogs that you may be faced with automating. However, getting all the nit-picky numbers straight to make a Control Manager based script actually work can be tough. RoboScripter is designed to do the heavy lifting for you in this area, giving you a script that you may be able to use "as-is" or perhaps with only slight modifications.
- WinMacro is a more traditional keystroke and mouse activity recorder. It converts the raw keystrokes and mouse activity into a WinBatch script.
WinMacro converts recorded activity into a WinBatch script on the fly when you use WinMacro in playback mode. It can also optionally create a file containing the same script. That way you can that can use (including modify) the script just like would any other WinBatch program you create.
The recorder also places the raw information into a small database. This makes it possible to recreate the playback script from the original data any time you want. This can be very useful when you break or misplace the original generated script.
- WIL Type Viewer
- The WIL Type Viewer is a WinBatch development tool that assists you in writing Component Object Model (COM) Automation based WIL scripts. The viewer can be used to examine the type information details of properties, methods, and events associated with an individual COM object or interfaces, enumerations, and classes defined in type libraries.
The viewer also allows you to browse lists of objects and type libraries registered on you system. You can view the detailed type information for these object and type library by simply selecting the item from a lists.
- WIL Dialog Editor
- The WIL Dialog Editor offers quick production of custom dialog boxes for your WinBatch programs.
It provides a convenient method of creating dialog box templates for use with the Dialog function.
It displays a graphical representation of a dialog box, and allows you to create, modify, and move individual controls which appear in the dialog box.
After you have defined your dialog box, the Dialog Editor will generate the appropriate WIL code, which you can save to a file or copy to the Clipboard for pasting into your WIL program.
You can include the dialog template code directly in your batch code, or you can use the batch language "Call" command to execute the dialog template.
Note: See the Windows Interface Language Reference help file for more details on how to use the Dialog function to further customize your dialogs, including adding callback procedures with in subroutines to make your dialogs dynamic.