
                          THE BATPOWER FAQ,
                    or Frequently Asked Questions

|     ***              Last revision: 06 Mar 02              ***

    +----------------------------------------------------------------+
    |     Table of Contents for     | 14. Path over 127 characters   |
    |  FREQUENTLY ASKED QUESTIONS,  | 15. What is the 'MUF'?         |
    |  (FAQ) for the BATPOWER Echo  | 16. Recursion/Loops in a BAT   |
    |-------------------------------+ 17. Start-up screen rotation   |
    |  1. How to reboot in a BATch  | 18. Tidying output from a BAT  |
    |  2. Communicate with a modem  | 19. Using ANSI codes in a BAT  |
    |  3. Date & Time Use in a BAT  | 20. REM or :: in a BATch       |
    |  4. Combine files into one    | 21. Is Windows/bat run from ?  |
    |  5. Formatting Disks Q&A      | 22. Using Ctrl+Z in a BATch    |
    |  6. Getting errorlevel Q&A    | 23. Zero byte files- questions |
    |  7. Help with making a menu   | 24. Banish 'Retry,Abort,Ignore'|
    |  8. Is TSR loaded in memory ? | 25. Getting user BATch input   |
    |  9. Jump back to prior dir    | 26. BATch Programming Books    |
    | 10. Find&Replace text in file ||27. BFDS FDN questions         |
    | 11. Low level HD format Q&A   | 28. Scripts posted in BATPOWER |
    | 12. FOR..IN..DO Q&A's         | 29. Test if D:\PATH exists ?   |
    | 13. Out of Environment Q&A's  ||30. Batch and the Internet?    |
    +----------------------------------------------------------------+


 1.                 HOW TO REBOOT IN A BATch
                    ~~~~~~~~~~~~~~~~~~~~~~~~
  Q: How do I reboot the PC from inside a batch file ?
  A:   ECHO G=FFFF:0 | DEBUG >NUL   for MSDOS} these occasionally
       ECHO GFFFF:0000 | SID >NUL   for DRDOS} will give garbage
    --------------------------------------------------------------
       ECHO HPS>REBOOT.COM    This seems reliable, most editors
       REBOOT.COM              will allow Alt+203 to get the 
                               Hold the ALT key while 2 0 3 is
                               entered at the r/h keypad
    --------------------------------------------------------------
       This DEBUG script will produce COLDBOOT.COM when you run it
    ------------------------------------+ thus:  DEBUG<SCRIPT.EXT
     If you're using  BNU type: BNU /B  |
     If you're using  X00 type: XU BOOT | N COLDBOOT.COM
     If you're using 4DOS type: REBOOT  | E 0100 48 50 53 CB 0D 0A
    ------------------------------------+ RCX
    Flush your Disk Cache before you use| 0006
     !!!!   ANY of these methods   !!!! | W
    for Smartdrive this is: SMARTDRV /C | Q


 2.                 COMMUNICATE WITH A MODEM
                    ~~~~~~~~~~~~~~~~~~~~~~~~
  Q: How do I communicate with my modem either in a BATch or on
     the command-line ?
  A: After setting up the COM port with MODE if required simply
     use DOS redirection > to ECHO AT commands to it.
     E.G. MODE COM1 baud=19200 data=8 parity=n stop=1
          ECHO AT&FF10\N4&D3E0M0Q1S0=1&W0>COM1
     might be used to set up a modem loading a profile into it
     or if you wanted to leave a computer accessible from a
     remote location you might shell out of a communications
     program and run a batch file containing:
          %COMSPEC% /e:1024 >COM1 <COM1
     which would start a copy of the command processor to accept
     input from the remote computer and output to it.
     (with MS-DOS error messages would not get sent but 4DOS
         allows STNDERR device writes to be re-directed)


 3.                 DATE & TIME USE IN A BAT
                    ~~~~~~~~~~~~~~~~~~~~~~~~
  Q: How do I create a LogFile or get the current Time & Date
     into environment variables.
  A: A number of utilities to get the time or date into an
     envar exist, among them are P2E, GET25, BATCHMAN & STRINGS
     but a pure MS-DOS solution exists too:
      VER|TIME|FIND "Current">$$TEMP$$.BAT
      ECHO SET CTIME=%%3>CURRENT.BAT
      $$TEMP$$.BAT
     will place the current TIME into an envar called CTIME and
     TIME can be replaced with DATE above to create CDATE.
     To create a log of system boots the following could be
     inserted into the AUTOEXEC.BAT file:
      ECHO -=-=-=-=-=-=-=-=-=-=-=-=-=-=->>BOOTLOG.TXT
      ECHO System booted !!! >>BOOTLOG.TXT      : For more   :
      VER|TIME|FIND "Current">>BOOTLOG.TXT      : techniques :
      VER|DATE|FIND "Current">>BOOTLOG.TXT      : type  $    :

    Using P2E to create filenames in YYMMDD.* format :
 @ECHO OFF
 ECHO.|DATE|P2E /E MM /L 1 /M 21,2 /E DD /L 1 /M 24,2 /E YY /L 1 /M 29,2
 ECHO This is a New File>%YY%%MM%%DD%.TXT

    Using PROMPT and CALL to create an 'ECHO'able Current Date & Time :
 @ECHO OFF
 ECHO @PROMPT LOG ON: $d at $t$h$h$h>C:\TEMP\TEMP$$$$.BAT
 %COMSPEC% /C C:\TEMP\TEMP$$$$|FIND ":">>C:\LOGONS.TXT
    Typical resultant contents of c:\logons.txt will be:
 LOG ON: Fri 12-27-1993 at 09:37:48
 LOG ON: Tue 01-04-1994 at 08:54:26
          --etc.--etc.--
    The section of the line between @PROMPT and the > is customizable
    and all $codes valid for the PROMPT command can be used as well as
    the current system date and time.


 4.                  COMBINE FILES INTO ONE
                     ~~~~~~~~~~~~~~~~~~~~~~
  Q: I have lots of text files that I want to combine into one,
     how can I automate this with a BATch.
  A: The DOS COPY command can be used or redirection of TYPE's
     output as follows:
         COPY *.TXT ALL.XXX
         RENAME ALL.XXX ALL.TXT
     or
         FOR %%f IN (*.TXT) DO TYPE %%f>>ALL.XXX
         RENAME ALL.XXX ALL.TXT
     The renaming of the resultant file is necessary, as when
     it is created by the first COPY or TYPE operation, were
     it called ALL.TXT it would immediately qualify for
     inclusion in the command as it would match the filespec.
     COPY can do binary concatenations too, with the /B param
     MS-Windows remakes WIN.COM everytime Setup is used similar
     to:  COPY /B WIN.CNF+VGALOGO.LGO+VGALOGO.RLE WIN.COM


 5.                  FORMATTING DISKS- Q & A
                     ~~~~~~~~~~~~~~~~~~~~~~~
  Q: How do I format a disk without DOS asking me questions ?
  A: With MS-DOS 3.3 use     FORMAT A: /H
     With MS-DOS 4.0+ use    FORMAT A: /AUTOTEST

     !!!  BEWARE - THIS WORKS ON HARD DISKS TOO !!!

     There are a number of other undocumented switches for both
     FORMAT and other MS-DOS features detailed in the MUF.
      (For information about the MUF see item # 15. below)


 6.                 GETTING ERRORLEVELS- Q & A
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~
  Q: How do I echo the errorlevel returned by a program to the
     screen so I can 'debug' my batch files ?
  A: There are a couple of utilities that can do this but the
     method used for the FAQ is the pure DOS solution below :

 @ECHO OFF
   :: Keeps the screen clean during execution of the batch file
 FOR %%A IN (0 1)                 DO IF ERRORLEVEL   %%A00 SET N=%%A
   :: This FOR loop executes twice, once for each element in the
   :: parenthesis.  %%A is replaced by 0 in the first execution, so the
   :: statement N=0 is stored in the environment no matter what the
   :: errorlevel is (IF ERRORLEVEL 000 means 0 or higher).  In the
   :: second execution, N will be set to 1 if the errorlevel is equal to or
   :: greater than 100.  Whichever value of N is stored, 0 or 1, it will be
   :: substituted below by the expression %N%.
 FOR %%A IN (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL %N%%%A0 SET N=%N%%%A
   :: This loop executes ten times.  If N starts off as equal to 0 from the
   :: previous FOR IN DO loop, then N will end up being 01, 02, ... 09 when
   :: the actual errorlevel is 10-19, 20-29, ... 90-99.
   :: Similarly, if the errorlevel is 100 or higher then N will end up
   :: being 10, 11, 12, ... up to 19.
 FOR %%A IN (0 1 2 3 4)           DO IF ERRORLEVEL   2%%A0 SET N=2%%A
   :: This loop corrects the previous one if the errorlevel is greater
   :: than 199.  N will be set to 20-24 in this step if the errorlevel is
   :: greater than 199.
 FOR %%A IN (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL  %N%%%A SET N=%N%%%A
   :: This loop will set the third digit of N, and will usually set N to
   :: the actual errorlevel.  However, if the errorlevel is 250 to 255,
   :: this loop will end up setting N=249 which would be incorrect.
   :: This glitch is resolved in the next FOR IN DO command below:
 FOR %%A IN (0 1 2 3 4 5)         DO IF ERRORLEVEL   25%%A SET N=25%%A
   :: This loop executes 5 times, but it doesn't alter N unless the
   :: errorlevel is 250 or greater, when it will set N to the actual
   :: errorlevel.
 ECHO ERRORLEVEL is %N%
   :: We should have a good errorlevel after all that, so it's time to
   :: display it to the screen.
 SET N=
   :: This statement removes N=??? from the environment.  You can skip
   :: this step if you want to use the stored errorlevel later in your
   :: batch file, recalling it with %N%.
 ----------------------------------------------------------------------
 Note, for those not wanting the 'details', simply remove all :: lines.


 7.                    HELP WITH MAKING A MENU
                       ~~~~~~~~~~~~~~~~~~~~~~~
    Q: How do I make a menu system with batch files ?
    A: Here's how you could do it with all BATs in a DIR in your PATH

        This is MENU.BAT            |          This is 3.BAT
 @ECHO OFF                          | @ECHO OFF
 CD\                                | CD\
 ECHO      MAIN MENU                | ECHO      GAMES MENU
 ECHO [1] Word Processor            | ECHO [31] DooM -Save The Universe!
 ECHO [2] Spreadsheet               | ECHO [32] FRAC -Tetris Clone 3D
 ECHO [3] Games                     | ECHO [33] Return To Main Menu
 ECHO.                              | ECHO.
 PROMPT Type the number and[ENTER]  | PROMPT Type the number and[ENTER]
 -------------+-------------+-------+------+--------------+--------------
 This is 1.BAT|This is 2.BAT|This is 31.BAT|This is 32.BAT|This is 33.BAT
   @ECHO OFF  |  @ECHO OFF  |  @ECHO OFF   |  @ECHO OFF   |  @ECHO OFF
   CD\WP51    |  CD\QPRO    |  CD\FUN\DOOM |  CD\FUN      |  CD\
   WP51.EXE   |  Q.EXE      |  DOOM.EXE    |  FRAC.EXE    |  CLS
   MENU.BAT   |  MENU.BAT   |  3.BAT       |  3.BAT       |  MENU.BAT


 8.               IS TSR LOADED IN MEMORY ?
                  ~~~~~~~~~~~~~~~~~~~~~~~~~
  Q: How can I test to make sure a TSR like ANSI.SYS is loaded?
  A: All memory-resident programs have to use memory and so an
     output from the MEM /C command will show them resident.
     The BATch below ('hook' needed) illustrates the technique.
     @echo off    -----
     if %1'==' goto syntax
     mem /c|find /i "%1">temp.tmp
     copy /b temp.tmp+,, >nul
     if exist temp.tmp echo Program: %1 was found in memory.
     if not exist temp.tmp echo Program: %1 is not loaded.
     if exist temp.tmp del temp.tmp
     goto end
     :syntax
     echo Usage: %0 [TSR to find in memory]
     echo        Example: %0 mouse
     :end


 9.          JUMP BACK TO PRIOR DRIVE / DIRECTORY
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Q: When I run a program or command how can I get back to the
     directory that was current prior to command execution ?
  A: Several solutions are available as small utilities but
     below is a pure DOS solution.(using environment variables)
     (4DOS has built in variables to deal with this situation)

     ::Set Envars to current drive & current directory
     @echo @prompt SET OLDRV$Q$N$_SET OLDIR$Q$P >C:\TEMP$TMP.BAT
     @%COMSPEC% /e:1024 /c C:\TEMP$TMP.BAT >C:\TEMP$$MP.BAT
     @call C:\TEMP$$MP.BAT >nul
     @del C:\TEMP$?MP.BAT

     Once this BATch has been CALL'd or run:
     %OLDRV% will be evaluated to be the drive when BAT was run
     and %OLDIR% will be evaluated to be the prior directory.


10.               FIND & REPLACE TEXT IN FILE
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Q: Is there a piece of software that does string search and
     replacement from the command line ?
  A: EDLIN (included with MS-DOS) is ideal for this.

     EDLIN FILENAME.EXT <REPLACE.SCR

     with the contents of REPLACE.SCR below

        1,#Rold string^Znew string
        e

     will replace every occurrence of "old string" throughout
     FILENAME.EXT with "new string"

  NB Using ^Z (Ctrl+Z) in a BATch is impossible as DOS sees it
     as an End-Of-File marker. Try Rob Flor's ALTER for BATches.


11.              LOW LEVEL HARD-DISK FORMATTING
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Q: How can LowLevel Format my Hard-Disk ? I heard you could
     use DOS's DEBUG command, is it true ?
  A: Older styles of drives (mostly MFM style) did have such
     routines situated in a Read Only Memory BIOS chip on their
     controller card. However some controllers had their code
     located at a different memory address to others. Below is
     the command to run this code for the most common types.

                      ECHO g=c800:5|DEBUG
     WARNING !
     Do not try this with Integrated Drive Electronics (IDE)
     type drives and if in doubt - Don't.

     Some IDE controllers will pretend to LLF, others will just
     hang the PC. It will not even work on ALL MFM type HD's.
     Some IDE's (apparently) can be damaged by attempting this.


12.                   FOR..IN..DO  Queries
                      ~~~~~~~~~~~~~~~~~~~~
  Q: How does this command work and what's the %%F stuff for ?
  A: The FOR..IN..DO command can be used either in batch files
     where you need to use %%F (two percent signs and variable)
     or at the prompt where only one percent sign is needed.
     In ordinary words the command is "With every member of
     this (collection of things) do this command". As with most
     DOS commands a little lateral thinking can lead to quite
     complex usage but in its simplest form you could replace
            DIR /B    with    FOR %F IN (*.*) DO ECHO %F
     (You would need to replace %F with %%F if used in a BATch)
     The %F or %%F is just a temporary variable only active
     while the FOR..IN..DO command is executing, the alphabetic
     character does not have any special meaning, it is just a
     'handle' for DOS to use to pass each member of the set at
     a time along to the DO part of the command. You could run
     all BAT's in sequence with   FOR %B IN (*.BAT) DO CALL %B


13.             "OUT OF ENVIRONMENT"  QUESTIONS
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Q: Often when I try and run BATch files they don't work and
     I get "Out of Environment Space" error messages, Why ?
  A: The 'environment' is used for variables like %PATH% and
     %PROMPT% and you may need to increase it's size for some
     BATch files that create there own variables to hold data.
     You can increase the size of the primary environment with
     the /E parameter in your SHELL statement in CONFIG.SYS
         E.G. SHELL=C:\DOS\COMMAND.COM C:\DOS /E:2048 /P
     or you could make a temporary adjustment for the BATch
     concerned by starting another copy of COMMAND.COM to run
     it, and specifying a larger environment size for it.
              E.G. %COMSPEC% /E:2048 /C SAMPLE.BAT
     Utilities like STRINGS give you the chance to perform math
     so you could test for adequate environment space in your
     own BAT's, for variables, & then use this method if needed.
       for more details of testing environment space type: !

  Example of BAT that tests env size for itself using STRINGS

   @echo off                       All this BATch does is run a
   STRINGS efree= ENVFREE          second copy of itself under
   STRINGS SUB 300, %efree% >nul   another copy of COMMAND.COM
   if errorlevel 1 goto DOIT       if environment space is less
   STRINGS esize= ENVSIZE          than 300 bytes, setting the
   STRINGS esize= ADD %esize%, 300 new environment to 300 bytes
   %comspec% /e:%esize% /c %0      bigger than the current.
   goto END                        If space is already >or= 300
   :DOIT                           it jumps to the DOIT label.
   echo We've got 300+ bytes space now!
   echo Environment Size: %esize% ; Environment Free: %efree%
   :END         +-----------------------------------------------
   set efree=   | With DOS you can check env. space usage with
   set esize=   | SET>TEMP.TMP then DIR TEMP.TMP filesize=usage


 14.             PATH GREATER THAN 127 CHARACTERS
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Q: How can I make my Path bigger than 127 characters long ?
  A: To use more than DOS's command-line limit of 127 chars
     you need to set the PATH in the CONFIG.SYS file (MSDOSv6+)
     or you use an utility like STRINGS or P2E.
     As an alternative you may give sections of a directory
     tree a label as if they were a separate drive. This will
     cut the length of the path statement used for that subdir.
     SUBST K: C:\WINDOWS ( use in AE.BAT before the PATH line )

     Using P2E: The following line in the Autoexec.Bat will
     set the path to the contents of the mypath.txt textfile.
     P2E Envar PATH <C:\MYPATH.TXT

     Using STRINGS: The following line in the AE.Bat will set
     the path to the contents of the mypath.txt textfile.
     STRINGS PATH= ASK <C:\MYPATH.TXT


15.                   WHAT IS THE 'MUF'?
                      ~~~~~~~~~~~~~~~~~~
  Q: I've been referred to the MUF for an answer or explanation
     to a problem I've posed. What, where, is it ?
  A: The MUF is a list of Microsoft(DOS) Undocumented Features
     It was compiled and edited by Gary Cooper from snippets in
     this echo and from a few other sources.
     Gary has passed the torch to Ron Warder, who will answer in
     the echo, or via FidoNet NetMail at :  1:109/132
  * The MUF is posted occasionally in the BATPOWER Echo, or
    can be obtained from many BBS's as MUF17.ZIP (as of 5-02-96)


16.            RECURSION / LOOPS IN A BATCH FILE
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Q: How do you do loops in a batch file ?
     And what is recursion / what do you use it for ?
  A: Both loops and recursion can be very useful because like
     other programming languages they can make batch files
     smaller and more effective users of disk space.
     Loops can be either unconditional jumps to a label using
     the GOTO command or by using IF EXIST or IF ERRORLEVEL can
     be made conditional. The BATch running now to show you
     these screens shows both these methods and also shows a
     command that effectively provides looping by performing a
     command for each member of a set of objects. That command
     is:  FOR %%[variable] IN ([set]) DO [command]
     Recursion is really just another sort of loop except that
     the batch file actually starts running another copy of
     itself, normally by executing %0 (its name as typed). This
     allows the batch to do work and restart to do more work.


17.                 START UP SCREEN ROTATION
                    ~~~~~~~~~~~~~~~~~~~~~~~~
  Q: Is there a way to rotate files, so that the same screen
     isn't displayed all the time ?
  A: One method of many available keeps screens in an archive
     until needed with all screens stored in their own subdir

      :ROTATE
      IF NOT EXIST SCREEN.??? PKUNZIP SCREENS.ZIP
      DEL SCREEN.BBS
      REN SCREEN.??? SCREEN.BBS
      REM done

     This same method could be used to rotate different BBS
     front screens or to rotate different .BMP or .RLE files
     so Windows wallpaper is rotated for each new session.


18.         TIDYING SCREEN OUTPUT FROM A BATCH FILE
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Q: How do I stop commands from displaying output on screen ?
  A: Just re-direct their output to the 'nul' device.
     E.G.   PAUSE>NUL    Will just wait for a keypress before
          continuing, without displaying the usual message:
          "Press any key to continue..."
     To hide error messages as well you'll need to use:
         CTTY NUL
         command that displays error you don't want to see
         CTTY CON
     Be Careful ! While CTTY NUL : the keyboard is ignored !

  Q: Sometimes when I execute a batch file after running I'm
     left with more than one prompt (as if I'd hit Enter).
  A: This is because the batch file has trailing carriage-
     returns. Use a plain text (ASCII) editor to remove them.
     Alternately, if you use: @Echo off
     as the first line of the batch file, the trailing <cr>'s
     will be ignored; hence, no multiple prompts.


19.        Using ANSI (escape codes) in a BATch File
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Q: I know I need to use an ESC character (Alt+27) to use
     ANSI codes but whenever I try DOS or Editors give me a
     slash or clear the line ?
  A: Use DOS EDIT and press Ctrl+P (which puts you in 'literal'
     mode) and then press Esc and you'll see a small left
     pointing arrow; this is the Esc character. Some editors
     like QEDIT allow you to use the numeric keypad to enter
     the Alt+27 sequence as well (or instead).
     Specialist ANSI screens editors like TheDraw can save you
     a lot of time and are much easier to use !
     To use ANSI in your PROMPT the $e code is an Esc character.

     If you use 4DOS use lines like the following instead;
         SCRPUT 6 34 BLINK BRIGHT RED ON BLUE W A R N I N G !
     This will write 'W A R N I N G !' in blinking bright red
     on a blue background with the W at row 6, column 34.


20.      Using REM or :: (double colons) in a BATch File
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Q: I heard double colons are better than REM statements, why?
  A: Even though a REM statement is a remark DOS will still
     read the whole line in case it's being re-directed.
     Double colons are seen as an invalid label by DOS when it
     starts to read the line so it skips on to the next line.
     The other way to speed up execution of a batch file that
     has lots of comments is to un-conditionally jump over the
     lines that are comments like this:
        @ECHO OFF
        GOTO START
        This is a comment line that'd slow down the BAT
        So is this line              -------------------------
        And so is this one as well   | Be careful using double
        :START                       |    colons with 4DOS !
        --continue-with-batch-file-- |::LABEL is a valid label.


21.    IS WINDOWS OR A BATCH FILE FROM WITHIN WINDOWS RUNNING ?
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Q: How can I make sure Windows isn't running before I run a
     program in a batch file ?
  A: Either use a purpose-made COM program such as ISWINRUN.COM
     a DEBUG script for which is below, it will exit with 1 as
     ERRORLEVEL if Windows is running , OR use the FIND command
     to look at the output of the MEM /C command to search for
     Windows' 'hook' in memory. If Windows is running in 386Enh
     mode a 'hook' called win386 will be in memory when you are
     in a DOS window. Solutions are outlined below:
     ----------------------------------------------------------
     nISWINRUN.COM
     e100 B8 80 46 CD 2F 3D 0 0 74 2 B0 1 34 1 B4 4C CD 21
     RCX    +--------------------------------------------------
     12     |  @ECHO OFF
     W      |  MEM /C|FIND /I "WIN">TEMP.$$$
     Q      |  COPY /B TEMP.$$$+,,>NUL
            |  IF EXIST TEMP.$$$ ECHO This is a DOS Window !
            |  IF EXIST TEMP.$$$ DEL TEMP.$$$
     ----------------------------------------------------------
                |  Yet another approach is in this ISWIN.BAT,
                |  which searches ENVMT for "windir".
     @ECHO OFF  +----------------------------------------------
     IF NOT "%WINDIR%."=="." ECHO Running under a WIN/DOS session
     IF "%WINDIR%."=="." ECHO Running under regular DOS only.


22.                 USING CTRL+Z IN A BATch
                    ~~~~~~~~~~~~~~~~~~~~~~~
  Q: How can you use Ctrl+Z in a batch file, whenever I put one
     in a BATch that's where execution of the BATch stops. ?
  A: This happens because Ctrl+Z is an End-Of-File Marker for DOS
     (EOF).  Using EDLIN in a BATch often needs the Ctrl+Z to be
     entered into a script and one of the few ways to do this is
     from the command prompt.

     Type:   SET ZED=[Ctrl+Z]  Replacing the bracketed text
                               with the real key combination.

     In BATch files thereafter you can use %ZED% where you are
     required to use a Control+Z key combination.

     As an example the batch file below, will search README.TXT
     & replace every instance of 'Marvelous' with 'Wonderful'.

     ECHO 1,#RMarvelous%ZED%Wonderful>test.scr
     ECHO e>>test.scr
     EDLIN README.TXT <test.scr


23.               ZERO BYTE FILES - Questions
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Q: Does a zero-byte file use a cluster of the disk ?
  A: NO ! However it does use one directory entry and so very
     occasionally should the file be in a subdirectory, the
     entry may need an extra cluster for the directory table.

     One of the features of zero-byte files is that MS-DOS will
     not copy them so  COPY /B filename.ext+,,  will delete the
     file if it is zero-byte or if it is not will reset its
     Date/Time Stamp to the system's current settings.
     To create a zero-byte file as a 'flag' use:  REM>FLAG.$$$
     Here's an example of how you might use this 'feature':
     CD\
     DIR /B /S|FIND /i "filename.ext">FLAG.$$$
     COPY /B FLAG.$$$+,,
     IF EXIST FLAG.$$$ ECHO filename.ext was found
     IF NOT EXIST FLAG.$$$ ECHO filename.ext is not on drive.


24.               BANISH 'Retry, Abort, Ignore'
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Q: How do you intercept DOS's error message that you get if
     you try and print to a printer that's not ready OR when
     you try to read or write to/from an empty drive.
  A: The command line switch for command.com /F will make all
     such situations default to Fail. You can add the /F to your
     SHELL statement in CONFIG.SYS, or you can use it in a .BAT
     as below as a temporary fix for single BATch execution

        @echo off
        if %1.==. goto END
        echo %comspec% /f /c cprn$$$$.bat>temp$$$$.bat
        echo copy %1 prn: >cprn$$$$.bat
        call temp$$$$.bat
        if exist ????$$$$.bat del ????$$$$.bat >nul
        :END
        echo Usage: %0 [filename to print]


25.                 GETTING USER BATch INPUT
                    ~~~~~~~~~~~~~~~~~~~~~~~~
  Q: How can I get my BATch files to interact with the user ?
  A: Too many utilities have been written, to overcome this
     short-fall in the MS-DOS BATch language, to detail here
     so just some are shown below, with use examples:

                 CHOICE  (comes with DOS v6.xx)
     This use of choice recognizes valid choices of A&B with a
     default to A after a 20 second wait and returns a prompt
     defined in the quotation marks

       ECHO  *[A] Word Pro.
       ECHO   [B] Database
       CHOICE /N /C:AB /T:A,20 "Enter Choice:"
       IF ERRORLEVEL 2 GOTO DATAB
       IF ERRORLEVEL 1 GOTO WORDP
       etc

                   INPUT  (comes with the FAQ)
     INPUT sets the errorlevel to the ASCII value of the
     keypress so EL check is best in 'bracketed' manner shown

       ECHO Do you want to Quit (Y/N)?
       INPUT 30
       IF ERRORLEVEL 89 IF NOT ERRORLEVEL 90 GOTO END
       IF ERRORLEVEL 121 IF NOT ERRORLEVEL 122 GOTO ELSE


26.                 BATCH PROGRAMMING BOOKS
                    ~~~~~~~~~~~~~~~~~~~~~~~
     While the following books have been recommended by various echo
     users, any choice should always be based on your personal
     examination of the book, to ensure that it meets your needs.

      DOS Power Tools                         by  Paul Somerson

      Supercharging MS-DOS                    by  Van Wolverton
                                                  and Dan Gookin

      MS-DOS Batch File Programming           by  Ronny Richardson

      Advanced MS-DOS Batch File Programming  by  Dan Gookin

      Enhanced MS-DOS Batch File Programming  by  Dan Gookin

      Batch Files and Beyond                  by  Dan Gookin

      Concise Guide to MS-DOS Batch Files     by  Kris Jamsa

      It is worth visiting: http://www.wambooli.com, Gookin's site.
      While there you can obtain ADVANCED/ENHANCED.ZIP, the files
      that accompanied (on diskette) the same-named books above.


27.                    BFDS FDN questions
                       ~~~~~~~~~~~~~~~~~~
  Q. I keep seeing references to the BFDS and BFDS FDN.  What is this
     and what is its significance?
  A. It stands for Batch File Distribution System, Files Distribution
     Network.  The Files Distribution Network is a large network that
     distributes many different types of shareware/freeware/PD files
     thru a 'conduit' called the Filebone.  The filebone is to Fido
     files, what the Backbone is to Fido echomail.  In addition to the
     filebone, there are a few other networks that carry the FDN files,
     chiefly, the Planet Connect (and other satellites) and the 3-COM
     Filegate.  The BFDS specializes in files of interest to the users
     of BATPOWER.  It was created as an adjunct to this echo, to make
     these files more easily available globally, as well as to reduce
     the need to post files as scripts in the echo.

  Q. How do I find a local source for these files?
  A. Well, keeping an up-to-date listing of the BFDS sites has proved
     to be a seemingly impossible task, for a number of reasons.  The
     best way for you to find out if there is a 'cache' of these files
     within your Net, is to ask the Sysop of the BBS from which you get
     BATPOWER, for a Net nodelist (an abbreviated nodelist of just the
     nodes (BBS's) within your net.  Search this listing with LIST.COM
     to F)ind NEC.  Not finding that, try the NC, the person at the top
     of the nodelist, on the line starting with: 'Host,'.  Ask them to
     help you locate a node within their net that is receiving the BFDS
     FDN.  Then log onto those BBS's and get their files listing.  You
     can then search that listing just as above, with LIST.  If none of
     this bears fruit, then ask the moderator in BP for some help,
     outlining the steps already taken.  You could also ask one of the
     BBS's that get BATPOWER to also subscribe to the BFDS FDN, which
     would ensure that any new releases will be available to you.  This
     can be done by sending a msg within the echo, asking that a
     BFDS-Kit be sent to (your node address). This will explain how to
     become a site. These files are also available thru the Internet via
|    FTP & http, URL's at the end of Item 30, or see 'Echo rules' posted
|    monthly in the BP echo, or in the FidoNet file: ELISTymm.zip.

28.                 Scripts posted in BATPOWER
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~

  Q. I see a few msgs that contain lines of characters with no spaces
     and no punctuation.  Looks like some sort of code.  What gives?
  A. These are called 'scripts', and they are indeed, encoded.  They are
     briefly covered in the 'Echo rules', and in much more detail in a
     separate posting 'Scripting guidelines', both posted twice monthly.
     Normally, just saving the msg to a plain ASCII text file, and
     deleting everything above the first line of code, then running it
     thru DEBUG will decode it (that is if the poster has followed the
     guidance in the above).  Each script is normally also preceded (or
     followed) by specific decoding instructions.  If the script is a
     multi-part msg, then each, in sequence, should be appended to the
     same text file.  Then, in addition to the above, all the unencoded
     headers/footers in between msgs should also be deleted.  Then
     saved, and run thru DEBUG, as per: DEBUG <filename
     Where filename is the text file to which you saved it.  It will
     help you if you choose the same rootname as the encoded file
     (usually an archive).
     EXAMPLE: The coded filename is FOOBAR1.LZH, save it as FOOBAR1.SCR,
     then, after deleting all above/between the codes,
     DEBUG <FOOBAR1.SCR  will result in FOOBAR1.LZH, which LHA will
     expand to the files being sent, one of which should be *.DOC.


29.          Testing for the existence of a directory
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  Q: How can I determine if a directory exists, regardless of
     whether or not it contains files ?
  A: You can do this by using the NUL device, since it exists in
     ALL dirs, empty or not.  Just use:  IF EXIST D:\PATH\NUL

     Will return a 'TRUE' whether D:\PATH\ is empty or has files.

     NOTE:  This is not always 'TRUE' in networked
     environments--in fact, seldom is.  Hence, one should not
     rely on this technique, except in a standalone environment.


30.      Batch files and the Internet - Recommended links
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  Q: What are some of the better DOS/batch links on the Internet?
  A: Here are a few of the better ones recommended by our users:

 alt.msdos.batch - Usenet newsgroup on MS-DOS batch programming
 Professor Timo Salmi's own batch material
            http://garbo.uwasa.fi/pc/batchutil.html
   at Garbo archives
            http://garbo.uwasa.fi/
    tsbat??.zip; A collection of useful batch files and tricks, T.Salmi
            ftp://garbo.uwasa.fi/pc/ts/tsbat??.zip  (69 at revision time)
 DOS Batch Language: A personal view A Web Book in Progress by Ted E. Davis
            http://gearbox.maem.umr.edu/~batch/index.htm
   or       http://gearbox.maem.umr.edu/~batch/multi.os.batch.programs.html
 Tips on integrating Win95 with DOS batch files Andrew Malek
            http://ourworld.compuserve.com/homepages/admalek/batch.htm
 Tom Lavedas' Batch File Utilities
            http://www.pressroom.com/~tglbatch/
 Batch Programming Stuff & Batch File Mini-FAQ*  - Terry Newton
            http://www.nc5.infi.net/~wtnewton/batch/
            http://www.nc5.infi.net/~wtnewton/batch/batfaq.html
 Batch Programming Elements - Collected by Dirk van Deun
            http://purl.oclc.org/net/dirk/batcoll.all
            http://purl.oclc.org/net/dirk/batvirus.all
 Windows 95 / DOS 7 Batch Programming - Webspace by Eric Phelps
            http://www.calweb.com/~webspace/batch/
 DOS Batch at Planet 16-bits
            http://home.sol.no/~westerma/planet/dos/dos_bat.html
 The Web-Based Guide to DOS; Everett Murdock Ph.D.
            http://www.csulb.edu/~murdock/easydos.html
 Gord's World of Batch Files
            http://www.hmtnet.com/users/gbraun/batch.htm
 Help-Site Computer Manuals - DOS
            http://help-site.com/c.m/dos
 Dan Gookin's (author of several batch primers) site, historical
            http://www.wambooli.com/not/archives/
 Rich Green's site, a good sourse of DOS util pgms and other links
            http://members.home.net/rlgreen2/softlib1.htm
 Horst Schaeffer's home page, author of the HORST series of batch tools
            http://www.online.de/home/horst.muc/int/
|cMech's MS-DOS Assembly utilities (many BATch oriented):
|           http://www.geocities.com/benritchey/masm.htm
 GREAT net site to do with BATCH run by Gord Braun...
            http://www.cableyorkton.com/users/gbraun/batch/index.htm
 Another good site for batch solutions to date manipulations by Gerry Danen
            http://www.geceventures.com
 Paul Quinn's 'down under' site for batch aids/solutions, from BATPOWER
            http://home.austarnet.com.au/quinn261/DOS_bats.html
 And finally, all the files distributed by the BFDS FDN can be had at:
            http://64.34.85.9/bfds  or
            ftp://64.34.85.9/pub/bfds

=====================================================================

The above 1-26 is a compilation of the information contained in the file:
BATFAQ11.ZIP, presented in an ASCII text format, and 'updated' as deemed
necessary, by the moderator, Bat Lang; first on 5-03-96, then as
indicated in the header.  We acknowledge the efforts of the many
BATPOWER users who contributed to this collection, and particularly to
our brethren in Zone:  3.  This collection, as an entity, is the
Copyright of the Fido Echo BATPOWER, and should receive credit as such.
Any of the above, used piecemeal, is considered in the Public Domain.

  Thanks for corrections/additions: Alexander Ng, John Gray, Douglas Myers,
Michael Marquart, Gary Laming, Robert Bull, Bruce Howells, Ben Ritchey,
et al.

Any comments, additions or corrections, should be submitted to the
moderator, addressed as below*.  Additions started with 27.

Moderator, BATPOWER

