BATCH FILE TIPS AND UTILITIES The Second in a series by Mitchell A. Hoselton AN INTRODUCTION TO CONFIG.SYS CONFIG.SYS is not a batch file. CONFIG.SYS can do things no batch file can do. It contains commands that no batch file can use. Except for REM, the initial colon (:) and BREAK, it can't use any of the commands or syntax that work in batch files. Nevertheless, the second article in this series about batch files concentrates exclusively on CONFIG.SYS. CONFIG.SYS merely creates the environment in which all batch files have to work. Like air, its effects are everywhere, though largely invisible and frequently ignored. Batch file programmers cannot afford to ignore the configuration or the consequences of the configuration choices made in CONFIG.SYS. This is only our first pass through the CONFIG.SYS file. It will make other appearances in this series. Batch file programmers inevitably end up writing and rewriting the CONFIG.SYS file, along with AUTOEXEC.BAT and most of the other batch files, too. AUTOEXEC.BAT is the most important batch file on any PC. CONFIG.SYS sets important limits on the options available when writing AUTOEXEC.BAT. Changing CONFIG.SYS usually requires making changes to AUTOEXEC.BAT and vice versa. There are a few utilities that can enhance the performance of CONFIG.SYS. This article introduces the best of the bunch. CREATING AND EDITING CONFIG.SYS, AUTOEXEC.BAT AND OTHER BATCH FILES To create and edit CONFIG.SYS, AUTOEXEC.BAT or any batch file, all anyone needs is an ASCII text editor. It is even possible to use a word processor and EXPORT or PRINT the text into an ASCII file. There are many options in the choice of an ASCII text editor. Every version of DOS includes the line editor called EDLIN. It isn't much of an editor, but it has written a lot of batch files. In some situations it is even indispensable. DOS 6.0 includes its own improved editor utility called EDIT. I prefer 1WORD, the editor built into XTreeGold version 2.5, a commercially available disk manager. The point is, there are plenty of available and easy to use ASCII editors. Any ASCII text editor will do. Find one, or get a friend to recommend one. After you find one you like, stick with it. The whole purpose for writing CONFIG.SYS is to install various device drivers and to set some crucial system parameters. In other words, to configure the PC system whenever the computer boots up. Some of the common device drivers conflict with each other, with resident programs installed from AUTOEXEC.BAT and/or with application programs. The configuration and device driver choices made while writing CONFIG.SYS can, therefore, limit the choice of compatible resident programs and applications. This is the situation that forces some users to create libraries of different CONFIG.SYS and AUTOEXEC.BAT files. There is a fundamental problem with editing CONFIG.SYS beyond finding an ASCII editor. After boot-up, there is no way to change the configuration without rewriting the CONFIG.SYS file and rebooting the computer. Most of us have learned to live with that. If there happens to be a fatal error (either a typo or a device driver conflict) in the revised CONFIG.SYS, the computer may crash during the boot process. In that situation there is no easy way to modify CONFIG.SYS to correct the error. The PC is not working, because it crashed during boot-up, and the ASCII editor can't work because it only runs on the PC. BOOTCON PREVENTS RECONFIGURATION CATASTROPHE The certain way to work around this difficulty is to prepare a boot floppy diskette in advance of any work on CONFIG.SYS. Then, if a fatal CONFIG.SYS error occurs, rebooting with the boot floppy in the A: drive will get the system working again. Every PC user should have a boot floppy available in the event of a total catastrophe. Booting from a boot floppy makes testing CONFIG.SYS an excruciatingly tedious process, however. Now there is a better way. BOOTCON is the answer. This month's report introduces BOOTCON, a utility that can switch among 26 different user defined configurations on the fly during the boot process. BOOTCON supplements rather than replaces the MBOOT utility introduced last month. Both utilities let the user make a selection from a menu at boot-up. MBOOT provides a selection among operating systems and BOOTCON provides a selection among groups of device drivers and system configuration parameters. It is even possible to use both utilities on one system at the same time. I currently use BOOTCON by itself since I only need one operating system, DOS 6.0. BOOTCON provides a safe and easy way to select different configurations at boot-up. It completely eliminates any need to swap pairs of CONFIG.SYS and AUTOEXEC.BAT files. It almost, but not quite, eliminates the need to keep a boot floppy. Best of all, BOOTCON virtually removes fatal crash worries while experimenting with different combinations of device drivers and system parameters. As long as one of the user defined configurations in BOOTCON works properly, the system can always be rebooted by selecting a working configuration from the BOOTCON menu. After successfully booting the PC, the user can edit the CONFIG.SYS file and try again. BOOTCON is published by Modular Software Systems, 115 W. California Blvd, Suite 113, Pasadena, CA 91105. It can be ordered from Modular Systems at (818) 440-9104 or from The Programmers Shop at (800) 421-8006. The price is $60. BOOTCON version 1.6 is compatible will all versions of DOS from 3.0 through 6.0. BOOTCON has a menu driven interface. It is customizable and has context sensitive help. It also offers password protection (except against someone with a boot floppy to stick in the A: drive). Features of the newly released version 1.6 include full DOS 6.0 compatibility, more customization options, a syntax checker for CONFIG.SYS and AUTOEXEC.BAT, enhanced password protection, and a new auto-boot utility. After it has done its work, BOOTCON shrinks down to occupy only 176 bytes of memory. USING BOOTCON TO CREATE A MULTIPLE CONFIGURATION CONFIG.SYS FILE Using BOOTCON requires three steps. The first is to add the BOOTCON device driver to the CONFIG.SYS file. Normally this command appears early in the CONFIG.SYS file. Listing other device drivers and configuration commands first is all right, if that is necessary or convenient. Adding BOOTCON to CONFIG.SYS requires typing in the following line. DEVICE=C:\BOOTCON\BOOTCON.SYS This assumes that BOOTCON.SYS is in the BOOTCON directory on drive C:. The second step in using BOOTCON is to define up to 26 "menu definition blocks" (MDBs for short) inside the CONFIG.SYS file. The MDBs appear after the BOOTCON.SYS command in CONFIG.SYS. Each MDB begins with a line that looks like the following example. REM BC=[ Label for this Menu Definition Block. Each MDB ends with a line that looks like the following example. REM BC=] The command lines between the REM BC=[ and REM BC=] execute only after making the appropriate selection from the opening BOOTCON menu. The text that constitutes the MDB label will appear on the BOOTCON menu and should, at the very least, tell the user something distinctive about that selection. The choices of text for the MDB label and of the lines within the MDB itself are entirely up to the CONFIG.SYS author. The third step in using BOOTCON is to add the following line at the very end of the CONFIG.SYS file. REM BC=[END] AN EXAMPLE: BOOTCON IN A REALISTIC CONFIG.SYS FILE In reading through the example in LISTING 1, it may be helpful to recognize a few important points as you go along. a) DOS allows blank lines to appear anywhere in CONFIG.SYS. In the example, they enhance readability both for this article and in the actual file on the hard disk. b) Under DOS versions before 4.00, MSDOS.SYS could transmit only capital letters from the CONFIG.SYS file to BOOTCON. No matter how an MDB label appears in the CONFIG.SYS file, the label appears to contain only capital letters when BOOTCON displays the menu. Under DOS 6.0 both capital and small letters display correctly. c) No matter which MDB you select from the BOOTCON menu, CONFIG.SYS statements that appear before, between and after the MDBs always execute . d) One MDB, usually the first one, is the default configuration. If no configuration is selected from the BOOTCON menu within a specified time, BOOTCON selects the default configuration. This relieves the user of any obligation to sit in front of the keyboard and monitor the boot process. The BOOTCON start-up menus can change the default configuration. e) The MDB labels appear on the BOOTCON menu in the order in which the MDBs appear in CONFIG.SYS. Each label will have a letter appended in front of it. The letters from "A" through "Z" appear in order. Make menu selections either by typing the letter that appears in front of the label for the required configuration or by moving the cursor to that label and pressing [RETURN]. f) The commands BREAK, BUFFERS, FCBS, FILES, LASTDRIVE, STACKS and SWITCHES can execute more than one time in a single CONFIG.SYS file. Only the last executed version of each command has an effect on the final configuration. The default value for these commands should appear at the beginning of CONFIG.SYS, before the first MDB. Then any MDB that requires a non-default value can include its own revised value for any particular configuration parameter. MDBs that use the default values do not need to include any of these configuration commands. g) Finally, the DOS= command represents a new type of DOS command. This particular command should only appear once in any CONFIG.SYS file. MSDOS.SYS will find this command even if it is in one of the MDBs not selected from the BOOTCON menu. The best way to handle this situation is to include the DOS=HIGH (or DOS=HIGH,UMB) command near the beginning of CONFIG.SYS. DOS will then load itself HIGH whenever it can. If CONFIG.SYS does not install a memory manager, DOS will load low. BOOTCON includes a special syntax convention to override the DOS= statement inside specific MDBs. A simplified version of a real CONFIG.SYS file containing BOOTCON and several MDBs might look like LISTING 1. =========================================================================== LISTING 1 - Sample CONFIG.SYS file 1 DEVICE=C:\QEMM\HOOKROM.SYS 2 3 DOS=HIGH 4 BREAK=ON 5 BUFFERS=35 6 FILES=25 7 LASTDRIVE=P 8 STACKS 0,0 9 SWITCHES=/K 10 11 DEVICE=C:\BOOTCON\BOOTCON.SYS 12 13 REM BC=[DOS 6.0 w/QEMM386, ANSI and DOS=HIGH 14 DEVICE=C:\QEMM\QEMM386.SYS RAM ROM 15 DEVICE=C:\DOS_620\RAMDRIVE.SYS 352 /A 16 DEVICE=C:\QEMM\LOADHI.SYS /R:2 C:\DOS_620\SETVER.EXE 17 DEVICE=C:\QEMM\LOADHI.SYS /R:2 C:\DOS_620\ANSI.SYS /k 18 REM BC=] 19 20 REM BC=[DOS 6.0 w/386MAX, ANSI and DOS=HIGH 21 DEVICE=C:\386MAX\386MAX.SYS PRO=C:\386MAX\386MAX.PRO 22 DEVICE=C:\386MAX\386LOAD.SYS PRGREG=2 PROG=C:\DOS_620\SETVER.EXE 23 DEVICE=C:\386MAX\386LOAD.SYS PRGREG=2 PROG=C:\DOS_620\ANSI.SYS /k 24 REM BC=] 25 26 REM BC=[DOS 5 w/HIMEM w/DOS HIGH 27 BUFFERS=25 28 FILES=20 29 DEVICE=C:\DOS_620\HIMEM.SYS 30 DEVICE=C:\DOS_620\SETVER.EXE 31 REM BC=] 32 33 REM BC=[DOS 5 w/HIMEM w/DOS LOW 34 REM BC=[DOS=LOW] 35 DEVICE=C:\DOS_620\HIMEM.SYS 36 DEVICE=C:\DOS_620\SETVER.EXE 37 REM BC=] 38 39 SHELL=C:\COMMAND.COM /P /E:656 40 41 REM BC = [END] =========================================================================== There will be more to say in later articles about the specific commands in LISTING 1. For now the emphasis is on BOOTCON and its capabilities. The following is a summary of what each statement or group of statements in the CONFIG.SYS file in LISTING 1 accomplishes. Line 1: Loads the HOOKROM.SYS device driver. QEMM386 requires HOOKROM.SYS when it is not the first device driver in CONFIG.SYS. HOOKROM.SYS does not interfere with 386MAX or HIMEM drivers. Line 3: Instructs DOS 6.0 to load itself into the high memory area. This command should appear early in the file. Even BOOTCON cannot prevent DOS from finding it. It does no good to include it in one of the "menu definition blocks." Include this line one time in CONFIG.SYS to be sure that DOS will load HIGH if a suitable memory manager is in the selected MDB. Lines 4-9: Typical CONFIG.SYS statements; they do not effect BOOTCON, BOOTCON does not effect them. They will execute no matter which MDB is selected from the BOOTCON menu. Commands in particular MDBs may override some of these. BOOTCON cannot protect against fatal errors that appear outside of one of the MDBs. Edit these lines with great care. Rebooting the system may require a boot floppy if there is an error in one of these lines. Line 11: Installs the BOOTCON.SYS driver. Line 13: Start of the first MDB; includes first MDB label. Lines 14-17: Will be executed if the first MDB is selected from the menu. Line 18: End of the first MDB. Line 20: Start of the second MDB; includes the second MDB label. Lines 21-23: Will be executed if the second MDB is selected from the menu. Line 24: End of the second MDB. Line 26 Start of the third MDB; includes the third MDB label. Lines 27-28: Override the BUFFERS and FILES commands at the beginning of the CONFIG.SYS file if the third MDB is selected from the menu. Lines 29-30: Will be executed if the third MDB is selected from the menu. Line 31: End of the third MDB. Line 33: Start of the fourth MDB; includes the fourth MDB label. Line 34: Overrides the DOS=HIGH command at the beginning of CONFIG.SYS if the fourth MDB is selected from the menu. This is a special BOOTCON syntax. Lines 35-36: Will be executed if the fourth MDB is selected from the menu. Line 37: End of the fourth MDB. Line 39: This SHELL command makes COMMAND.COM the primary command processor and increases the primary DOS environment to 656 bytes. Edit this line carefully. A boot floppy may be required to reboot the PC if there is an error in this line. Line 41: Marks the last line in the CONFIG.SYS file. It is required by BOOTCON. DOS starts processing this CONFIG.SYS file and eventually gets around to loading and executing BOOTCON. BOOTCON reads the entire CONFIG.SYS file and presents a four item Start-up Menu as shown in LISTING 2. =========================================================================== LISTING 2 - BOOTCON Start-up Menu ============================================================= | Select A Configuration... F1=Help | ============================================================= | A - DOS 6.0 w/QEMM386, ANSI and DOS=HIGH | | B - DOS 6.0 w/386MAX, ANSI and DOS=HIGH | | C - DOS 5 w/HIMEM w/DOS HIGH | | D - DOS 5 w/HIMEM w/DOS LOW | ============================================================= ================================================= | Auto Select Countdown... 9 Seconds Remain | | | | Press [Spacebar] to abort Auto Select, | | or any other key to continue... | ================================================= =========================================================================== The BOOTCON menu can display up to 15 selections on one page. If the CONFIG.SYS file defines more than 15 MDBs, BOOTCON allows the user to access the extra MDBs by their prefix letter or by scrolling down through the list with the cursor. Pressing the F1 key while the BOOTCON menu is active, resets and freezes the Auto Select timer and displays the BOOTCON Help Menu shown in LISTING 3. =========================================================================== LISTING 3 - BOOTCON Help Menu ========================BOOTCON Help=========================== | Move the highlighted selection bar to the boot option you | | want to use and press [ENTER], or press the letter next to | | the option you want to select. Press [ESCAPE] if you don't | | want any of the options. | | | | Other options are: | | F1 - Display this help window | | F2 - Display system information | | F3 - Program Configuration Menu | | F9 - View the CONFIG.SYS file | | F10 - View the AUTOEXEC.BAT file | | ESC - Exit the program | | | | Press any key to continue... | =============================================================== =========================================================================== Exiting from the BOOTCON Help menu and pressing F3 displays the BOOTCON Configuration Menu shown in LISTING 4. ========================================================================== LISTING 4 - BOOTCON Configuration Menu ==Program Configuration== | | | BOOTCON Customization | | Advanced Options | | Set System Password | | Set Advanced Password | | Lose Changes and Exit | | Save Changes and Exit | ========================= =========================================================================== Selecting BOOTCON Customization from the Configuration Menu produces the Customization Menu in LISTING 5. =========================================================================== LISTING 5 - BOOTCON Customization Menu ======================BOOTCON Customization====================== | Default Menu Selection : A (A-Z, blank=last used) | | Audio Enabled : N (y/n) | | Phaser Count : 0 (0-9) | | Auto Select : 15 (1-999), 0 to disable) | | Exploding Windows : Y (y/n) | | Remove Video Snow : Y (y/n) | | Clear Screen on Startup : Y (y/n) | | Maximum Vertical Menu Height : 15 (0-15 rows) | | Maximum Horizontal Menu Width : 55 (0 or 30-74 columns) | | | | OK Cancel Revert Defaults | ================================================================= =========================================================================== In LISTING 2 and LISTING 5 Auto Select indicates the count-down time in seconds to make a selection. Moving the cursor halts the Auto Select timer. If the Auto Select timer runs out before the user makes a selection, BOOTCON installs the default configuration. From the BOOTCON Customization menu it is possible to change the default configuration, control the sound effects that alert the user to the appearance of the BOOTCON menu, control whether windows around the menus are exploding, adjust the size of the window and adjust the video driver for the clearest display. BOOTCON will restore the default values as a last resort. Save any changes on the Program Configuration menu. EFFECTS OF BOOTCON ON AUTOEXEC.BAT Using BOOTCON does not necessarily require making any changes in the AUTOEXEC.BAT file. Almost inevitably, however, what happens in CONFIG.SYS determines what AUTOEXEC.BAT can do and how it should do it. For example, installation of a memory manager may enable AUTOEXEC.BAT to load programs into high memory. The loading syntax for these programs in AUTOEXEC.BAT is different when loading them into high memory or low memory. The syntax changes with each memory manager, too. Clearly, there are command lines that AUTOEXEC.BAT should execute only when CONFIG.SYS installs a particular memory manager. The sample menu shows BOOTCON offering to install three different memory managers. Each has its own loading commands. AUTOEXEC.BAT must determine which memory manager CONFIG.SYS installed and execute the appropriate commands. To help programmers work around these complications, BOOTCON creates a DOS environment variable called BOOTCON. If the user chooses the second menu item from the BOOTCON menu, BOOTCON adds the string BOOTCON=B to the DOS environment. BFCL (Batch File Control Language) commands in AUTOEXEC.BAT can check the value of this environment variable and chose which commands to execute based on the current value of the BOOTCON environment variable. Next month we'll see how this works as we begin examining AUTOEXEC.BAT and the DOS environment. I will also introduce a new utility, called ISDEV, that can detect the device drivers installed by CONFIG.SYS. KEY WORDS 1WORD 386MAX.PRO 386MAX.SYS ANSI.SYS ASCII Text Editor ASCII (American Standard Codes for Information Interchange) Auto Select Countdown Auto Select Timer AUTOEXEC.BAT A: (A Colon - 1st floppy diskette drive on a PC) Batch File Batch File Control Language BFCL Boot Floppy Diskette Boot Process BOOTCON Configuration Menu BOOTCON Customization Menu BOOTCON Help Menu BOOTCON Menu BOOTCON - Default Configuration BOOTCON.SYS (Modular Software Systems) Boot-Up BREAK BUFFERS Colon (:) COMMAND.COM Configuration Configuration Parameter CONFIG.SYS CONFIG.SYS - Blank lines in Crash (PC keyboard lockup, general PC system failure) Device Driver Conflict Device Drivers Device= DOS DOS Environment DOS= DOS=HIGH DOS=HIGH,UMB EDIT EDLIN FCBS FILES HIMEM.SYS HOOKROM.SYS (QEMM386 support utility) ISDEV LASTDRIVE LOADHI.SYS MBOOT MDB Label MDB (Menu Definition Block) Memory Manager (386MAX, QEMM386, HIMEM, NETROOM etc.) Menu Driven Interface Modular Software Systems MSDOS.SYS Operating System PC (Personal Computer) Programmers Shop, The QEMM386.SYS RAMDRIVE.SYS Rebooting Reconfiguration Catastrophe REM REM BC=[ Label REM BC=[DOS=LOW] REM BC=[END] REM BC=] SETVER.EXE SHELL STACKS SWITCHES XTreeGold (by XTree Company)