Home Page 5
Index Next Page
DOS for Windows9x

Creating Batch Files

Topics
Forma.batFormatting floppies Batch files for use with the Registry:
Dback.batCopying Data Files to Backup Reg.bat1. Backup, Compacting & Restoring
Dirp.batListing Directory contents Regbak.bat2. Backup & Restoring only
Bootlog.batLogging Bootups    
CallUsing other files to repeat commands Main topic Index
~ Topics listed in Green are essential, I believe. ~     ~ Those in Blue are less so, but are still useful. ~
Please start at the beginning, to understand how Batch files work.

What Are Batch Files?
Batch files ( *.bat ) are DOS files containing one or more commands to be run in DOS mode, rather like macros. Running a batch file simply directs its pre-written commands to be obeyed, just as if they had been typed individually at the DOS Prompt. Before Win9x they were used extensively to run 'batches' of commands, and could be very lengthy. Holding numerous commands (especially strings of switches) in one file saves time and typing errors! They still have a place within Win9x systems, depending upon what is required by the user. Some program upgrade patches are supplied with batch files to apply the fixes.

NB: If you create and keep Batch files in   C:\   or   C:\BATS\   add them to the PATH statement in   C:\AUTOEXEC.BAT.   Edit the line as appropriate to read:
       PATH C:\WINDOWS;C:\WINDOWS\COMMAND;C:    or
       PATH C:\WINDOWS;C:\WINDOWS\COMMAND;C:;C:\BATS    (directories separated by semi-colons)

Now let's create a some Batch files. Most are simple, two slightly more complex. In the examples the batch files are written in lower case except where display text is included. This is the conventional method, which you don't have to follow. It tends to be easier to read - and troubleshoot! - in longer ones. The explanations use capital letters for clarity.
top of Page     Main topic Index

Forma.bat
This simple batch file consists of just a command line. It formats a floppy and gives it a standard name, and is suitable for using DOS to clear a number of floppies. There is a useful purpose for it - formatting floppies under DOS reduces the risk of a virus infection.
  1. Ensure you are in the C:\ directory.
  2. Type    edit forma.bat    [Enter]
  3. In the blank window, which will be headed FORMA.BAT, enter the following line:
    format a: /u /c /v:MY_NAME
    
    where 'MY_NAME' is your name (eg JOHN_SMITH). You are allowed 11 characters, with no spaces or full stops, hence the _ separator. This labels the floppy as yours.
  4. Save the file (Alt-F-S) and Exit the editor (Alt-F-X)
  5. Run the file by typing just    FORMA    [Enter]
  6. Follow the instructions. Keep feeding the floppies in until you have finished, then press 'N' and Enter. The file will stop running.
top of Page     Main topic Index

Dirp.bat
This file is a bit more decorous and will give you a Directory listing of all the files in the current directory, in name order, excluding sub-directories, a page at a time. For details of the command see Dir.   As with "Forma.bat" above, the aim of the file is to save typing the rest of the switches each time. We'll call the file   Dirp.bat   and again save it in the root directory, so it will always be available.
  1. Ensure you are in the C:\ directory.
  2. Type    Edit dirp.bat    [Enter]
  3. In the blank window, which will be headed DIRP.BAT, enter the following lines:
    @echo off
    cls
    dir /a-d /o:-gn /v /p
    echo.
    echo        **** End of Directory Listing ****
    echo.
    
  4. Save the file (Alt-F-S) and Exit the editor (Alt-F-X)
  5. Run the file by typing    dirp    [Enter]
  6. That gives you a listing of the files in C:\. Change directory to a rather larger one:
         CD \windows    [Enter]   and run the file again.
  7. As the listing will be rather long this time, to break out of the Batch command, simply press Ctrl+Break
Explanation:
  • @ECHO OFF - Tells DOS not to 'echo' (type) each command on screen, and not to show the command not to 'echo' on screen, either! This prevents duplicated lines appearing.
  • CLS - Tells DOS to Clear Screen (ie start with a fresh screen)
  • ECHO. - Produces a blank line. Note the full stop.
  • ECHO - Tells DOS to display some text ('echo it to the screen'). It makes it look better in this case. Note the spaces between the word 'echo' and the asterisks, to indent the displayed text.
  • DIR etc - Gives the actual command, whose switches you do not wish to try to recall each time!
  • The whole could be reduced to just the DIR line, but why not add a bit of decoration?
Top of Page     Main Topic Index

A Batch File for Backing Up Data

Dback.bat
This next file is a 'template' for you to adapt to your setup. It uses Xcopy in a DOS Box to perform a simple backup, copying all the files in three directories holding Data from one drive ( C: ) to another ( D: ). If you don't have a backup utility like WinZip or a Zip Drive you need something better than laboriously using Explorer to copy files to floppies. And if you don't have a D: drive (as a partition or a separate Hard Disk) either, then do something about it now! A partition is cheaper than a second Hard Disk or a Zip drive.
  1. Open Notepad.
  2. In the blank window type (or copy and paste in) the following lines:
    @echo off
    c:
    cls
    echo.
    echo   ======== DBACK.BAT   -   DATA BACKUP ========
    echo   = Copies Data Files from Drive C to Drive D =
    echo   ** Close all programs with open Data Files **
    echo   =============================================
    echo.
    echo   === Press a key to start Backup Copying ====
    pause
    XCOPY /C /E /U /I /A /K /Q C:\DOCS\*.* D:\DOCS\*.*
    XCOPY /C /E /U /I /A /K /Q C:\DBASE\*.* D:\DBASE\*.*
    XCOPY /C /E /U /I /A /K /Q C:\IMAGES\*.* D:\IMAGES\*.*
    echo.
    echo   ======== DBACK.BAT   -   DATA BACKUP ========
    echo   =        Finished copying Data Files        =
    echo   =============================================
    echo.
    pause
    cls
    
  3. Edit the directory paths as they apply to your setup.
  4. Save the file As   C:\DBACK.BAT   and Exit Notepad.
  5. Open a DOS Box.
  6. Run the file by typing just    DBACK    [Enter]
Note: The first time you run the file, edit it to omit the   /U   switch, as there will be nothing to Update yet! Simply copy the   XCOPY   lines and paste them at the very end, then put   rem   at the beginning of those lines. Then remove the   /U   from the original lines and save the file. After running it the first time, you can edit it again - the 'remmed-out' lines will be there to remind you of the switch.   REM   is useful for trying variations of a command.

The general format and batch file commands used are as explained under the other example files. This one adds more text to explain what it is happening, but essentially it just runs the three   XCOPY   lines.
This file is for use in a DOS Box, as the switches used are applicable to   XCOPY32   which is automatically used under Windows. If you would prefer to use it in DOS Mode, amend the switches as appropriate.
Top of Page     Main Topic Index

A Batch File for Logging Bootups

Bootlog.bat
This quite simple batch file causes a date and time entry to be added to the end of a file called   C:\Boot.txt   each time the machine is started or rebooted.
  1. Open Notepad. Save the blank file, with nothing in it (unless you want to give it some kind of Header) as   C:\Boot.txt .
  2. Ask Notepad for a New text file. In the blank window type (or copy and paste in) the following lines:
    @echo off
    REM Bootup Date and Time recorder
    echo.Next Bootup: >>c:\boot.txt
    echo.|date|find "Current" >>c:\boot.txt
    echo.|time|find "Current" >>c:\boot.txt
    
  3. Save this file as   C:\Bootlog.bat .
  4. Open your   C:\Autoexec.bat   and towards the end add:
    CALL BOOTLOG.BAT
    
    Save it.
  5. Shut down Windows and choose " Restart the computer? "
  6. Use Notepad to open   C:\Boot.txt  . It will eventually collect a series of entries, looking like this:
    Next Bootup:
    Current date is Tue 09/12/2003
    Current time is  16:36:49.02
    Next Bootup:
    Current date is Tue 09/12/2003
    Current time is  19:02:43.82
    Next Bootup:
    Current date is Tue 09/12/2003
    Current time is  22:13:33.59
    Next Bootup:
    Current date is Wed 10/12/2003
    Current time is  20:33:26.44
    
Explanation:
  • From this you can keep track of how many times you have rebooted to install something, or how often and when the machine is used etc.
  • @echo off - Prevents DOS displaying the commands on-screen.
  • REM - Indicates a 'Remark' line which DOS ignores. The line is there to say what the batch file does.
  • echo. - Tells DOS to display a specified text, but the " >> " signs tell it to redirect that text to the specified document (rather than screen) and add the text to the end of the file.
  • |date|find   &   |time|find - Tell DOS to get the date and then time.
  • "Current" - Tells DOS to output the specified text together with the date and then time in the format above, as a readable sentence.
  • Bootlog.bat is invoked by the   CALL command. See below for more on Call.
Top of Page     Main Topic Index

Registry Backup, Restoring, Exporting & Compacting

Reg.bat
This file is designed to work with the Guide to Compacting the Registry, to make the typing of commands at the DOS Prompt less time consuming and error-prone. In fact, with this file you don't type anything except the choice of action offered by the Menu system, which you will find very simple and easy to adapt to any other batch file you decide to use. Please read the Guide before using the Compact Registry option included.

We're going to use Notepad to create the file. Please do not use Wordpad or any other word processor. Word processors add formatting and all we want is plain text, where the only non-character key is the carriage-return (ie Enter) to end one line and begin another.

I suggest you copy and paste the text rather than try typing it line by line - hence Notepad. A DOS Box, which might seem a logical choice, does not work because the DOS Editor copies and pastes using its own 'buffer' rather than the Windows Clipboard. Look at the file in detail to see what is happening once it has been saved.
  1. Select and copy the text below (from   @echo off   as far as the last   cls  ) from your browser into the clipboard, and open Notepad. Yes, it does look long, but you'll see why when you run it - much if it is text.
    @echo off
    c:
    cd c:\windows
    REM - Author's note -
    REM - THE FILE PATHS ARE GIVEN IN FULL. THIS IS NOT STRICTLY NECESSARY -
    REM - AND IN A COUPLE OF PLACES THE FULL PATH MUST BE OMITTED -
    REM - End of note -
    cls
    echo.
    echo       **********************************************************
    echo       *  REGISTRY BACKUP, EXPORTING, COMPACTING and RESTORING  *
    echo       *                                                        *
    echo       *                     WARNING!                           *
    echo       *                                                        *
    echo       *    Using this utility may be harmful to your system.   *
    echo       *    If you have not yet read the Guide to Compacting    *
    echo       *              the Registry you should Quit now.         *
    echo       *                                                        *
    echo       * - DO NOT RUN THIS FILE FROM A DOS BOX UNDER WINDOWS! - *
    echo       **********************************************************
    echo.
    choice /c:YN /n Have you read the Guide - Yes or No?
    if errorlevel 2 goto Quit
    if errorlevel 1 goto Menu
    :Menu
    cls
    echo.
    echo       ***************************************************************
    echo       *  REGISTRY BACKUP, EXPORTING, COMPACTING and RESTORING Menu  *
    echo       *                                                             *
    echo       *    This file assumes your Windows folder is C:\Windows      *
    echo       *  If it is not, Quit, open this file, correct the path in    *
    echo       *  all lines where it occurs, save the file and re-run it.    *
    echo       +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    echo       *  You will return to this menu after each step. Follow the   *
    echo       *  1-2-3 order below unless you have good reasons not to.     *
    echo       *                                                             *
    echo       *  1  Backup the Registry           2  Export the Registry    *
    echo       *                 3  Compact the Registry                     *
    echo       *                                                             *
    echo       *  R  Restore an already backed-up Registry        Q  Quit    *
    echo       *                                                             *
    echo       * (NB: Windows programs like RegClean cannot be run from DOS) *
    echo       ***************************************************************
    echo.
    choice /c:123RQ Choose your next Step
    if errorlevel 5 goto Quit
    if errorlevel 4 goto Restore
    if errorlevel 3 goto Compact
    if errorlevel 2 goto Export
    if errorlevel 1 goto Backup
    :Backup
    cls
    echo.
    echo     ***************************************************************
    echo     * Backing up Registry. Previous backup copies will be renamed *
    echo     *       C:\Windows\System.ba1  and  C:\Windows\User.ba1       *
    echo     *                                                             *
    echo     *   To continue press any key. To Quit now press Ctrl+Break   *
    echo     *          When asked, press  F  to specify  File             *
    echo     ***************************************************************
    echo.
    pause
    attrib -r -a -s -h c:\windows\system.dat
    attrib -r -a -s -h c:\windows\user.dat
    if exist c:\windows\system.ba1 del c:\windows\system.ba1
    if exist c:\windows\user.ba1 del c:\windows\user.ba1
    if exist c:\windows\system.bak ren c:\windows\system.bak system.ba1
    if exist c:\windows\user.bak ren c:\windows\user.bak user.ba1
    xcopy c:\windows\system.dat c:\windows\system.bak
    xcopy c:\windows\user.dat c:\windows\user.bak
    attrib +r +a +s +h c:\windows\system.dat
    attrib +r +a +s +h c:\windows\user.dat
    echo.
    echo      **************************************************************
    echo      * Your Registry has been Backed up.  The files were saved as *
    echo      *    C:\Windows\System.bak   and   C:\Windows\User.bak       *
    echo      *                                                            *
    echo      * Any previous Backup versions with these names were renamed *
    echo      *    C:\Windows\System.ba1   and   C:\Windows\User.ba1       *
    echo      **************************************************************
    echo.
    pause
    cls
    goto Menu
    :Export
    cls
    echo.
    echo      +++++++++++++++++++++++++++++++++++++++++
    echo      + Exporting Registry.   This may take   +
    echo      +      some time. Please Wait .....     +
    echo      +++++++++++++++++++++++++++++++++++++++++
    echo.
    if exist c:\export.re1 del c:\export.re1
    if exist c:\export.reg ren c:\export.reg export.re1
    regedit /e c:\export.reg
    echo.
    echo      +++++++++++++++++++++++++++++++++++++++
    echo      *  Your Registry has been Exported    *
    echo      *  The file is called C:\Export.reg   *
    echo      *                                     *
    echo      *  Any previous version has been      *
    echo      *               renamed C:\Export.re1 *
    echo      *                                     *
    echo      * Press any key to return to the Menu *
    echo      +++++++++++++++++++++++++++++++++++++++
    echo.
    pause
    cls
    goto Menu
    :Compact
    cls
    echo.
    echo     ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    echo     +  This choice will Compact Registry using C:\Export.reg   +
    echo     +                                                          +
    echo     +                   *** WARNING ***                        +
    echo     +  If you have not already Backed up, you should stop and  +
    echo     +                      do so now.                          +
    echo     +                                                          +
    echo     +  1  Backup     2  Continue Compacting           Q  Quit  +
    echo     +                                                          +
    echo     ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    echo.
    choice /c:12Q Choose your next Step
    if errorlevel 3 goto Quit
    if errorlevel 2 goto Compnow
    if errorlevel 1 goto Backup
    :Compnow
    cls
    echo.
    echo     ***           DO NOT INTERRUPT COMPACTING                ***
    echo.
    regedit /c c:\export.reg
    echo.
    echo     +++++++++++++++++++++++++++++++++++++++
    echo     *  Your Registry has been Compacted   *
    echo     *                                     *
    echo     * Press any key to return to the Menu *
    echo     +++++++++++++++++++++++++++++++++++++++
    echo.
    pause
    cls
    goto Menu
    :Restore
    cls
    echo.
    echo     *******************************************************
    echo     *  Restoring your Registry from Backups. Please Wait  *
    echo     *******************************************************
    echo.
    attrib -r -a -s -h c:\windows\system.dat
    attrib -r -a -s -h c:\windows\user.dat
    xcopy c:\windows\system.bak c:\windows\system.dat
    xcopy c:\windows\user.bak c:\windows\user.dat
    attrib +r +a +s +h c:\windows\system.dat
    attrib +r +a +s +h c:\windows\user.dat
    echo.
    echo     +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    echo     * Your Registry has been Restored from the Backup files *
    echo     *   C:\Windows\System.bak  and  C:\Windows\User.bak     *
    echo     *  The two backup files have been retained as copies    *
    echo     +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    echo.
    pause
    cls
    goto Menu
    :Quit
    cd\
    cls
    
  2. Click on Paste and Save the file As   C:\Reg.bat.
  3. Have a look at it to work out what it means - you'll soon find it simple enough. It will help if you print it. Copy the text again into a Word Processor if you dislike Notepad's clumsy output.
  4. Close Notepad and Windows. Then Shut Down and choose either "Restart the computer" or "Restart in MS-DOS Mode", and run the file. Just type   REG   at the prompt. As it is in the root C:\ directory, it will run from any Prompt.
  5. You will see the first Menu displayed, waiting for you to make a Choice. The file may seem very lengthy, but if you answer Y (Yes) to the initial Menu, and take the first two steps offered from the second, main Menu (neither of which change anything, but create two files), you will see how the process works and can relate it to the batch file.

The commands included are explained in Essential Commands. With regard to the batch file itself:
Explanation:
  • C: - ensures DOS is working on drive C:
  • CD C:\WINDOWS - changes Directory to C:\Windows, where the files to be worked with are.
  • REM - A 'Remark' line. Anything in the line will be ignored. It is often used to temporarily disable a line or to add notes about the commands, as here.
  • CLS - Clears the Screen to ensure the Menu text is fully and clearly displayed
  • ECHO. - Leaves a line blank at the top of the screen.
  • ECHO - Displays the text. We have added some 'decoration'.
    The setting out of text in this way at key points makes it clear to the user what options are available, what is happening as the result of a choice, and what has happened once it has been processed. The passages perform a similar function to Windows' Dialogue Boxes.
  • Note that the Menus displayed specify which key to press for a particular action.
  • CHOICE /c:YN /n Have you read the Guide - Yes or No?:
    • CHOICE    indicates a Menu.
    • /C:YN    specifies that the choice must to be Y or N
    • /N Have you read the Guide - Yes or No?    specifies that DOS should not (as it does by default) repeat the choice, and only displays the text.
      In the CHOICE menus after the opening one, DOS will repeat the options, as /N is not given.
    • if errorlevel 2 goto Quit
      if errorlevel 1 goto Menu
      These must be given, and in reverse order. 'Errorlevel' means 'choice made' (ie key pressed). 'Errorlevel 2' is N and 'Errorlevel 1' is Y.
    • GOTO    tells DOS where the command is, specified in the text below and indicated by a colon (:). In this first CHOICE it will go to ':Menu' (which follows immediately) or ':Quit' (which is at the very end as it is the Exit choice for several menus).
  • :Menu - starts the section for the main Menu. The CHOICE for it is different, but still specifies the keys to be pressed, the 'errorlevels' in reverse order, and the sections to 'goto' depending upon the key pressed.
  • :Quit - holds nothing (apart from changing the current directory back to the root C:\ and 'clear screen' to restore the cursor/prompt to the top), so the file ends, and the user is returned to the Command Prompt.
      :End   is often used to denote the final (exit) command in a batch file with a Menu. I happen to prefer Quit, but it could be anything. As with the other Section names (:Backup, :Export, :Compact, :Compnow, :Restore) the word itself is insignificant, but it must be exactly the same as given after ' GOTO ' and is case-sensitive.
  • PAUSE - stops the action to allow the user time to read the displayed (echoed) messages. It automatically displays the line: " Press any key to continue "
Top of Page     Main Topic Index

Backing Up & Restoring Only

Regbak.bat
This batch file is designed to Backup or Restore Registry, and save you the chore of typing the commands. If you compare it with Reg.bat above, you'll see it is a cut-down version. Like Reg.bat, it should only be run in DOS Mode - not in a DOS Box - and like Reg.bat it retains backups. The commands in both vary slightly therefore from those given in Patrick's Guide to Compacting the Registry, which is recommended reading before you use this.

  1. Open Notepad, as we'll use the copy-&-paste method to create the file.
  2. Select and copy the text below from your browser into the clipboard, and turn to Notepad.
    @echo off
    rem  - This file assumes your Windows folder is C:\Windows.
    rem  - If it is not, edit this file to correct the path in all
    rem  - lines where it occurs, save the file and re-run it.
    c:
    cd c:\windows
    goto Menu
    :Menu
    cls
    echo.
    echo       *************************************************************
    echo       *            REGISTRY BACKUP and RESTORING Menu             *
    echo       *                                                           *
    echo       *            B  Backup the Registry                         *
    echo       *            R  Restore Registry from last Backup           *
    echo       *            Q  Quit                                        *
    echo       *                                                           *
    echo       *************************************************************
    echo.
    choice /c:BRQ Choose your next Step
    if errorlevel 3 goto Quit
    if errorlevel 2 goto Restore
    if errorlevel 1 goto Backup
    :Backup
    cls
    echo.
    echo     ***************************************************************
    echo     * Backing up Registry. Previous backup copies will be renamed *
    echo     *       C:\Windows\System.ba1  and  C:\Windows\User.ba1       *
    echo     *                                                             *
    echo     *   To continue press any key. To Quit now press Ctrl+Break   *
    echo     *          When asked, press  F  to specify  File             *
    echo     ***************************************************************
    echo.
    pause
    attrib -r -a -s -h c:\windows\system.dat
    attrib -r -a -s -h c:\windows\user.dat
    if exist c:\windows\system.ba1 del c:\windows\system.ba1
    if exist c:\windows\user.ba1 del c:\windows\user.ba1
    if exist c:\windows\system.bak ren c:\windows\system.bak system.ba1
    if exist c:\windows\user.bak ren c:\windows\user.bak user.ba1
    xcopy c:\windows\system.dat c:\windows\system.bak
    xcopy c:\windows\user.dat c:\windows\user.bak
    attrib +r +a +s +h c:\windows\system.dat
    attrib +r +a +s +h c:\windows\user.dat
    echo.
    echo      **************************************************************
    echo      * Your Registry has been Backed up.  The files were saved as *
    echo      *    C:\Windows\System.bak   and   C:\Windows\User.bak       *
    echo      *                                                            *
    echo      * Any previous Backup versions with these names were renamed *
    echo      *    C:\Windows\System.ba1   and   C:\Windows\User.ba1       *
    echo      **************************************************************
    echo.
    pause
    cls
    goto Menu
    :Restore
    cls
    echo.
    echo     *******************************************************
    echo     *  Restoring your Registry from Backups. Please Wait  *
    echo     *******************************************************
    echo.
    attrib -r -a -s -h c:\windows\system.dat
    attrib -r -a -s -h c:\windows\user.dat
    xcopy c:\windows\system.bak c:\windows\system.dat
    xcopy c:\windows\user.bak c:\windows\user.dat
    attrib +r +a +s +h c:\windows\system.dat
    attrib +r +a +s +h c:\windows\user.dat
    echo.
    echo     +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    echo     * Your Registry has been Restored from the Backup files *
    echo     *   C:\Windows\System.bak  and  C:\Windows\User.bak     *
    echo     *  The two backup files have been retained as copies    *
    echo     +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    echo.
    pause
    cls
    goto Menu
    :Quit
    cd\
    cls
    
  3. Click on Paste and then Save the file As   C:\Regbak.bat.
  4. Shut down to DOS Mode, and run the file:   REGBAK    [Enter]
Notes:
  • REM    explains what a user should do to make the file correspond to a different setup.
  • GOTO MENU    at the top tells the file to begin the ' :Menu ' display immediately.
  • When Restoring Registry this file's commands use Backups you have already made with it or with Reg.bat, rather than the more often suggested use of   USER.DA0   and   SYSTEM.DA0   so run the Backup first - preferably when sure your system is working correctly!
  • The reason for this is that a system can already have begun to develop a problem when Windows creates its 'backups', whereas if you use a backup from some days (not months) before, it is less likely to be about to fall over anyway.
  • To be of real use you must refresh the Backup after changing system settings, or adding or removing programs or hardware. With luck you will never need the Restore option!
Top of Page     Main Topic Index

Using Several Batch Files for Repeated Commands

Using Call
As you can see above, one file can contain numerous commands invoked as required via the 'Choice' menu creation facility. However, they can get very long and complicated. Where a batch file includes either one command you frequently use or several commands (which may either just run one after another or be selectable via a menu) there is no point repeating them again in another file. The second can simply 'call' the first, and carry on after it has finished.

Suppose you regularly restart your computer in DOS-mode to back up your Registry after each session. You could semi-automate this by adding at the top of your C:\Windows\Dosstart.bat file, eg:
       @ECHO OFF
       CALL REG.BAT
       C:\MOUSE\MOUSE.COM
       C:\WINDOWS\COMMAND\MSCDEX.EXE /D:CDROM1 /L:F
The effect of this would be to run Reg.bat (as above). This would give you total control, as you could Quit without backing up if you wished to, or decide (if the Windows session you just ended seemed flaky) to restore the last Registry backup immediately and try Windows again.   The fully automated alternative - putting the command lines to backup instead - would destroy the option by making backups of possibly corrupt files.   Once Dosstart.bat has done its job of calling another file, it will continue to process any commands below the 'CALL' line, in this case loading the DOS Mouse driver and enabling access to the CD-ROM drive, then terminate itself as normal.

A 'Call' can be placed anywhere within a batch file, the advantage being that it keeps the main file running. Say you have another batch file and want it to use the Registry facilities in Reg.bat and then do some other tasks. If you were to put in simply:
       REG.BAT
it would launch the Reg batch file but stop running itself.

Bootlog.bat:
  • The reason for using 'Call' with Bootlog.bat instead of adding the lines to Autoexec.bat (which you could do if you wish, without the '@Echo off' line) is to keep Autoexec simple.
  • The logging can be de-activated by merely adding 'REM' to the beginning of the 'Call' line, and then re-enabled by removing 'REM' again. This is a lot easier than re-writing the commands, which remain safe in Bootlog.bat.
  • It also helps disguise the existence of the logging from the curious who don't understand DOS !
If you do find DOS useful, and write a few batch files, bear 'Call' in mind if you find you are repeating the same command lines in them.
Top of Page     Main Topic Index

Next Page

< Home >