home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / texts / txtfiles_misc / batch.txt < prev    next >
Text File  |  1995-01-19  |  49KB  |  1,272 lines

  1.                          Computer Help References
  2.                              version 1.19.95
  3.  
  4. ────────────────────────────────────────────────────────────────────────────
  5.                        B A T C H    L A N G U A G E
  6. ────────────────────────────────────────────────────────────────────────────
  7.  
  8. As new information is added, it will appear at the beginning of each
  9. specific section.  All new information will have the date it was added in
  10. the header.  If you find something you've read before that is marked as a
  11. new addition, it is due to a correction, or addition to that topic.
  12.  
  13. ────────────────────────────────────────────────────────────────────────────
  14.  
  15. DOS Punctuation Primer
  16. ======================
  17. -> Added on January 18, 1995
  18.  
  19. Symbol       : `+'
  20. What it is   : COPY file "concatenator".
  21. What it does : Tells the COPY command to combine the contents of several
  22.                small files, or the contents of a file plus text you enter
  23.                from the keyboard "console" (CON), into one big file.
  24. Uses         : 1. To copy and combine both DOS startup files into one
  25.                   archive called STARTUP.FIL, type
  26.  
  27.                    COPY AUTOEXEC.BAT+CONFIG.SYS STARTUP.FIL
  28.  
  29.                2. To add a new line "REM End of file" to the bottom of your
  30.                   existing AUTOEXEC.BAT file without having to use a word
  31.                   processor or text editor, go to the DOS prompt and type
  32.  
  33.                    COPY AUTOEXEC.BAT+CON
  34.                    REM End of File
  35.                    ^Z
  36.  
  37.                   (For the ^Z, either hold down the CTRL key and press Z, or
  38.                   just press F6) and hit ENTER.
  39.  
  40.                3. You can also use the + sign to make corners of crude
  41.                   comment boxes:
  42.  
  43.                    +-------+
  44.                    :       :
  45.                    +-------+
  46.  
  47. Symbol       : `:'
  48. What it is   : Batch file label designator.
  49. What it does : Indicates a label designation for a GOTO command.
  50. Uses         : 1. To see if your DOS directory contains a copy of DEBUG.COM
  51.                   or DEBUG.EXE, the DBUGHUNT.BAT batch file below uses
  52.                   :DEBUG_YES, :DEBUG_NO, and :END labels, which tells DOS
  53.                   where to jump to for each of the batch file's GOTO
  54.                   commands.
  55.  
  56.                    @echo off
  57.                    REM This is DBUGHUNT.BAT
  58.                    IF EXIST \DOS\DEBUG.* GOTO DEBUG_YES
  59.                    GOTO DEBUG_NO
  60.                    :DEBUG_YES
  61.                    ECHO It's Here
  62.                    GOTO END
  63.                    :DEBUG_NO
  64.                    ECHO DEBUG is missing
  65.                    :END
  66.  
  67.                   While you can use long labels, DOS only looks at the first
  68.                   eight characters, so to DOS, :LONGLABEL1 and LONGLABEL2
  69.                   are the same (it sees both as :LONGLABE).  If your batch
  70.                   file contains what DOS thinks are duplicate copies of the
  71.                   same label, it will always use the one closer to the
  72.                   beginning of the batch file.
  73.  
  74.                   Labels must contain a colon (:) as the first character.
  75.                   Since DOS won't execute anything after a colon, you can
  76.                   also use colons as you would REM commands to add REMarks
  77.                   and comments to your batch files if you're careful.  You
  78.                   could make the second line of DBUGHUNT.BAT read
  79.  
  80.                    :This is DBUGHUNT.BAT
  81.  
  82.                   However, if you had included a GOTO THIS command in the
  83.                   batch file, DOS might try to jump to such a comment line,
  84.                   thinking that ":This" was a label.  So to be safe, if you
  85.                   DO use colons to leave comments, simply add a second colon
  86.                   such as
  87.  
  88.                    ::This is DBUGHUNT.BAT
  89.  
  90.                2. You can also use the colon to make sides of crude boxes.
  91.  
  92.                    +-------+
  93.                    :       :
  94.                    +-------+
  95.  
  96. Symbol       : `.'
  97. What it is   : ECHO blank line generator.
  98. What it does : When used directly after the command ECHO with no extra
  99.                spaces thrown in, it displays a blank line on screen.
  100. Uses         : To have a blank line onscreen before and after the box around
  101.                the following warning, use a pair of ECHO commands:
  102.  
  103.                 @echo off
  104.                 REM This is MUSTDO.BAT
  105.                 ECHO.
  106.                 ECHO +-------------------+
  107.                 ECHO : Back up every day!:
  108.                 ECHO +-------------------+
  109.                 ECHO.
  110.  
  111.                The period after the ECHO is different from the one that DOS
  112.                uses to preface a filename extension like .BAT or .EXE  And
  113.                it's also different from the single period that DOS uses to
  114.                indicate the current directory, as it does in
  115.  
  116.                 COMP B: .
  117.  
  118.                to have DOS COMPare the files on drive B: with those in the
  119.                current directory.
  120.  
  121.                Note: This works with DOS 3.0 or later versions; earlier DOS
  122.                versions handle ECHOing blank lines differently.
  123.  
  124. Symbol       : `@'
  125. What it is   : Batch file display suppressor.
  126. What it does : Prevents batch files from displaying lines and cluttering up
  127.                the screen unnecessarily.
  128. Uses         : ECHO OFF will prevent all subsequent lines from displaying
  129.                onscreen, unless a particular line is expressly designed to
  130.                display something.  But since this suppression capability
  131.                doesn't go into effect until the line after the ECHO OFF, the
  132.                ECHO OFF itself will normally display.  Prefacing this (or
  133.                any line) with an @ sign will prevent that one particular
  134.                line from displaying.  Generally, all batch files should
  135.                begin with an
  136.  
  137.                 @ECHO OFF
  138.  
  139.                line.  These two batch files work essentially the same way:
  140.  
  141.                 @ECHO OFF
  142.                 REM This is SILENT1.BAT
  143.                 ECHO Only this line will appear
  144.  
  145.                 @REM This is SILENT2.BAT
  146.                 @ECHO Only this line will appear
  147.  
  148.                Note: This requires DOS 3.3 or later to work.
  149.  
  150. Symbol       : `>'
  151. What it is   : Redirect-and-overwrite symbol.
  152. What it does : Redirects DOS output to a file and overwrites and existing
  153.                file that happens to have the specified name.
  154. Uses         : DOS can shift, or "redirect", the output of a file, device,
  155.                or command from it's usual desination to a different file or
  156.                device.  When redirecting output to a file, using a single >
  157.                sign creates a brand-new file and overwrites any existing
  158.                file with the same name (see >>).
  159.                1. To print a DIR listing, type
  160.  
  161.                    DIR > PRN
  162.  
  163.                2. To suppress a "... file(s) copied" message after a COPY
  164.                   operation, add > NUL to the end:
  165.  
  166.                    COPY *.* B: > NUL
  167.  
  168.                3. To redirect the output of a DIR C: command and create a
  169.                   new file called DIRFILE (which would overwrite any
  170.                   existing file that has the same name), type
  171.  
  172.                    DIR C: > DIRFILE
  173.  
  174.                   If you subsequently typed
  175.  
  176.                    DIR A: > DIRFILE
  177.  
  178.                   DOS would wipe out the DIR C: contents of DIRFILE and
  179.                   create a new file containing just the directory listing of
  180.                   drive A:
  181.  
  182.                NOTE: This requires DOS 2.0 or later to work.
  183.  
  184. Symbol       : `>>'
  185. What it is   : Redirect-and-append symbol.
  186. What it does : Redirects DOS output to a file and eithercreates a new file
  187.                if one with the specified name doesn't already exist, or adds
  188.                ("appends") the new information to the end of an existing
  189.                file with the specified filename (see >).
  190. Uses         : 1. If no file called DIRFILE already exists, the following
  191.                   line will create a brand-new DIRFILE file containing a
  192.                   DIR C: listing:
  193.  
  194.                 DIR C: >> DIRFILE
  195.  
  196.                   If a DIRFILE already exists, DOS will append a DIR C:
  197.                   listing to it.  If you type
  198.  
  199.                    DIR C: >> DIRFILE
  200.  
  201.                   and then
  202.  
  203.                    DIR A: > DIRFILE
  204.  
  205.                   DOS will also append the directory listing of drive A: to
  206.                   the DIRFILE file.
  207.  
  208.                NOTE: This requires DOS 2.0 or later to work.
  209.  
  210. Symbol       : `<'
  211. What it is   : Redirect-input-from-file symbol.
  212. What it does : While DOS normally expects input to come from the keyboard,
  213.                in some cases you can tell it to use a file for input
  214.                instead.
  215. Uses         : To view the contents of a long text file called LONGTEXT.FIL,
  216.                type
  217.  
  218.                 MORE < LONGTEXT.FIL
  219.  
  220.                Be careful not to switch the < symbol around.  Do *NOT* type
  221.                MORE > LONGTEXT.FIL, or you will wipe out the LONGTEXT.FIL
  222.                contents!
  223.  
  224.                NOTE: This requires DOS 2.0 or later to work.
  225.  
  226. Symbol       : `|'
  227. What it is   : Pipe symbol.
  228. What it does : A DOS pipe makes the output of one command serve as the input
  229.                for another command.
  230. Uses         : 1. To view the contents of a long text file called
  231.                   LONGTEXT.FIL, type
  232.  
  233.                    TYPE LONGTEXT.FIL | MORE
  234.  
  235.                   Here the output of the TYPE command becomes the input for
  236.                   MORE.
  237.  
  238.                2. To delete all the files in a directory and bypass the "Are
  239.                   you sure (Y/N)?" prompt, pipe the ECHOed keystroke Y into
  240.                   the DEL command:
  241.  
  242.                    ECHO Y | DEL *.*
  243.  
  244.                   Don't try this unless you really want to erase everything!
  245.  
  246.                3. The most common pipe operation is to feed the FIND filter.
  247.                   To see a compact list of all your nonhidden
  248.                   subdirectories, type
  249.  
  250.                    CHKDSK /V | FIND "Di"
  251.  
  252.                   DOS 5.0 lets you try to do this with a new DIR switch:
  253.  
  254.                    DIR \ /AD /S | FIND "Di"
  255.  
  256.                   but this won't locate hidden subdirectories, either.
  257.  
  258.                NOTE: This requires DOS 2.0 or later to work.
  259.  
  260. Symbol       : `%0, %1 ... %9'
  261. What it is   : Replaceable parameter.
  262. What it does : Lets a batch file use information sent to it from outside the
  263.                batch file.  DOS replaces any %0 it sees inside a batch file
  264.                with the very first thing that appears on the command line
  265.                after the DOS prompt.  Since the first thing after the DOS
  266.                prompt is the name of the batch file itself -- usually
  267.                without the .BAT extension -- %) always represents the name
  268.                of the batch file (at least initially; SHIFT can later change
  269.                this).  DOS replaces any %1 it sees in a batch file with the
  270.                first thing you typed on the command line _after_ the name of
  271.                the batch file.  It replaces %2 with the second thing you
  272.                typed after the batch file, and so on, up to %9.  It uses
  273.                "delimiters" to separate each thing you typed.  The most
  274.                common delimiter is a space, but DOS will treat semicolons,
  275.                commas, and equal signs as delimiters too.  SHIFT can later
  276.                change the way DOS interprets these replaceable parameters.
  277. Uses         : The following TALKBAK1.BAT batch file will display up to nine
  278.                words that you enter at the DOS prompt after the word
  279.                TALKBAK1; the first word will replace %1, the second %2 and
  280.                so on.  TALKBAK1.BAT uses the special parameter %0 to display
  281.                the name of the batch file itself.
  282.  
  283.                 @ECHO OFF
  284.                 REM This is TALKBAK1.BAT
  285.                 ECHO This is %0.BAT
  286.                 FOR %%A in (%1 %2 %3 %4 %5 %6 %7 %8 %9) DO ECHO %%A
  287.  
  288.                To have a batch file process more than nine replaceable
  289.                parameters, use the SHIFT command.  TALKBAK2.BAT will display
  290.                as many words as you type on the command line after TALKBAK2.
  291.  
  292.                 @ECHO OFF
  293.                 ECHO This is %0.BAT
  294.                 :TOP
  295.                 IF %1!==! GOTO END
  296.                 ECHO %1
  297.                 SHIFT
  298.                 GOTO TOP
  299.                 :END
  300.  
  301.                While replaceable parameters are normally used to handle
  302.                things that you type on the command line, they also work well
  303.                with FOR ... IN ... DO %%A variables and CALL commands.  In
  304.                the following pair of batch files, BATCH1 calls BATCH2 and
  305.                passes parameters from BATCH1 to BATCH2.  BATCH1 will ferret
  306.                out all the .BAT files in your directory and pass the names
  307.                to BATCH2; BATCH2 will display the names one by one and then
  308.                display the contents of the files.  The %%A in BATCH1 is like
  309.                the pitcher; the %1 in BATCH2 is like the catcher.
  310.  
  311.                 @ECHO OFF
  312.                 REM This is BATCH1.BAT
  313.                 FOR %%A IN (*.BAT) DO CALL BATCH2 %%A
  314.  
  315.                 REM This is BATCH2.BAT
  316.                 ECHO %1
  317.                 MORE < %1
  318.                 PAUSE
  319.  
  320. Symbol       : `%%A'
  321. What it is   : FOR ... IN ... DO batch file variable.
  322. What it does : Lets the FOR ... IN ... DO command perform repeated
  323.                operations inside a batch file on a set of files or commands.
  324. Uses         : The DOSFILS1.BAT batch file will copy all your .COM, .EXE,
  325.                and .SYS files from the current directory on drive C: to a
  326.                floppy in drive B:
  327.  
  328.                 @ECHO OFF
  329.                 REM This is DOSFILS1.BAT
  330.                 B:
  331.                 FOR %%A IN (C:*.COM C:*.EXE C:*.SYS) DO COPY %%A
  332.  
  333.                DOSFILS2.BAT will do this and the erase the originals:
  334.  
  335.                 @ECHO OFF
  336.                 REM This is DOSFILS2.BAT
  337.                 B:
  338.                 FOR %%A IN (COPY ERASE) DO %%A C:*.COM
  339.                 FOR %%A IN (COPY ERASE) DO %%A C:*.EXE
  340.                 FOR %%A IN (COPY ERASE) DO %%A C:*.SYS
  341.  
  342.                NOTE: FOR ... IN ... DO variables require double %% prefixes
  343.                      when used in batch files, but just single % prefixes
  344.                      when used directly at the DOS prompt.
  345.  
  346. Symbol       : `%A'
  347. What it is   : FOR ... IN ... DO nonbatch file variable.
  348. What it does : Lets the FOR ... IN ... DO command perform repeated
  349.                operations on a set of files or commands on the command line
  350.                at the DOS prompt.
  351. Uses         : To see help for all the external DOS 5.0 commands (assuming
  352.                your DIS files are all in a DOS directory), type
  353.  
  354.                 FOR %A IN (\DOS\*.COM \DOS\*.EXE) DO %A /?
  355.  
  356.                NOTE: FOR ... IN ... DO variables require double %% prefixes
  357.                      when used in batch files, but just single % prefixes
  358.                      when used directly at the DOS prompt.
  359.  
  360. Symbol       : `%ENV_VAR%'
  361. What it is   : Environemt variable.
  362. What it does : Lets your batch files use the DOS environment as a place to
  363.                store variables, and gives batch files access to the
  364.                important DOS settings already stored there (PATH, PROMPT,
  365.                COMSPEC, and so on).
  366. Uses         : The DOS PROMPT command can issue tricky ANSI.SYS
  367.                color-setting Escape sequences.  Normally this would change
  368.                your PROMPT, but you can store a copy of the current prompt
  369.                as an OLDPROMPT environment variable and then later retrieve
  370.                the stored value as %OLDPROMPT%  This works only from inside
  371.                batch files.  SHOWCOL.BAT assumes ANSI.SYS has already been
  372.                loaded at boot-up time in CONFIG.SYS (with a like like
  373.                DEVICE=\DOS\ANSI.SYS), and it will display six different
  374.                foreground colors on a black background.  Make sure you leave
  375.                a blank line before the @CLS !!
  376.  
  377.                 @REM This is SHOWCOL.BAT
  378.                 @SET O=%PROMPT%
  379.                 @PROMPT $E[0;40m
  380.                 @FOR %%A IN (6 5 4 3 2 1 1) DO PROMPT $E[3%%Am
  381.                 @PAUSE
  382.                 @PROMPT $e[34;47m
  383.  
  384.                 @CLS
  385.                 @SET PROMPT=%O%
  386.  
  387.                NOTE: Environment variables were not documented before
  388.                      Version 3.3 and worked erratically (or not at all) in
  389.                      some earlier DOS versions.  To use the environment as a
  390.                      variable storage area, you'll probably have to expand
  391.                      your default environment size with a line in your
  392.                      CONFIG.SYS like this one:
  393.  
  394.                       SHELL=C:\DOS\COMMAND.COM C:\DOS\ /E:1024 /P
  395.  
  396. Symbol       : `=='
  397. What it is   : IF string-test equal sign.
  398. What it does : Lets IF test whether two chracter strings are the same.
  399. Uses         : All batch files that need user-entered parameters should
  400.                start out with an "IF %1!==! GOTO OOPS" test:
  401.  
  402.                 @ECHO OFF
  403.                 REM This is ANYBATCH.FIL
  404.                 IF %1!==! GOTO OOPS
  405.                 REM (Guts of batch file go here)
  406.                 GOTO END
  407.                 :OOPS
  408.                 ECHO You didn't enter anything!
  409.                 :END
  410.  
  411.                If the user enters anything at all on the command line after
  412.                the name of the batch file, DOS replaces the %1 with what the
  413.                user entered.  If the user entered
  414.  
  415.                 ANYBATCH Hi Mom
  416.  
  417.                DOS will make %1 equal to Hi, and will make the IF test:
  418.  
  419.                 IF Hi!==! GOTO OOPS
  420.  
  421.                Hi! is not equal to !, so the test fails, and the batch file
  422.                doesn't jump to :OOPS.  But if the user doesn't enter
  423.                anything after the name of the batch file, the test becomes
  424.  
  425.                 IF !==! GOTO OOPS
  426.  
  427.                and since ! is clearly equal to !, DOS will jump to the :OOPS
  428.                label.
  429.  
  430. * PC Computing - DOS Power Tools from Paul Somerson
  431.  
  432. ────────────────────────────────────────────────────────────────────────────
  433.  
  434. Where to put the "PATH" Statement
  435. =================================
  436. -> Added on January 12, 1995
  437.  
  438. Most people pud the PATH in the beginning of their AUTOEXEC.BAT   Your PATH
  439. is stored in the environment (along with your PROMPT, COMSPEC, and whatever
  440. other environment variables you may set).
  441.  
  442. Every TSR (Terminate and Stay Resident) program (like MOUSE.COM) that DOS
  443. loads gets a copy of the current environment.  Because of this, the more you
  444. have in your environment when a TSR is loaded, the more memory that
  445. particular TSR will require.  Therefore, it's best to load TSR's _before_
  446. setting any environment variables.
  447.  
  448. * Vernon.Frazee@f71.n135.z1.fidonet.org
  449.   or FidoNet: 1:135/71
  450.  
  451. ────────────────────────────────────────────────────────────────────────────
  452.  
  453. Thinning Your AUTOEXEC.BAT
  454. ==========================
  455. -> Added on January 12, 1995
  456.  
  457. If you have a bunch of variables pointing to the TEMP directory (such as TMP,
  458. TEMP, LIST, etc.) there is a shortcut you can use.  A powerful feature of
  459. BATCH language is the FOR xx IN ... DO ... command.  Here's an example of
  460. setting 3 variables (TMP, TEMP, and LIST) to "C:\TEMP" -- all in one line.
  461.  
  462.     for %%x in (TEMP TMP LIST) do set %%x=c:\temp
  463.  
  464. * Vernon.Frazee@f71.n135.z1.fidonet.org
  465.   or FidoNet: 1:135/71
  466.  
  467. ────────────────────────────────────────────────────────────────────────────
  468.  
  469. Re-Booting your Computer
  470. ========================
  471. -> Updated on January 3, 1995
  472. -> Added on December 12, 1994
  473.  
  474. For MS-DOS, the following will reboot your computer ...
  475.    echo G=FFFF:0 | DEBUG >NUL
  476.  
  477. For DR-DOS, the following will reboot your computer ...
  478.    echo GFFFF:0000 | SID >NUL
  479.  
  480. Both of the above methods occassionally will give garbage and leave files
  481. sitting around.
  482.  
  483.  
  484. Another way is to use "echo HPS*>REBOOT.COM" to create a mini-program called
  485. REBOOT.COM   You have to replace the * character above with -->  ╦  <--
  486. If you can see an "outlined-T" that's what you want.  You have to hold down
  487. the <ALT> key and type "203" without the quotes to get that character.
  488.  
  489.  
  490. If you run a BBS, or have a Communications Fossil loaded, you can use
  491. whichever one of the following match your Fossil Driver ...
  492.  
  493.     If you are using  BNU type: BNU /B
  494.     If you are using  XDO type: XU BOOT
  495.  
  496.  
  497.   **********************************************************************
  498.   **                                                                  **
  499.   **  Flush your Disk Cache before you use any of these methods !!!!  **
  500.   **  If you use Smartdrive, the command is: SMARTDRV /C              **
  501.   **                                                                  **
  502.   **********************************************************************
  503.  
  504. * Unknown Source - Sorry!
  505.  
  506. Here's a couple of programs you can cut and paste, feed into DEBUG and keep
  507. in your "Batch" directory.
  508.  
  509. To use the following programs, you'll need to save everything between the two
  510. --->CUT HERE<--- lines *EXACTLY* as you see here, into a plain ASCII text
  511. file.  Once that's done, at the DOS prompt, type
  512.  
  513.     DEBUG < filename
  514.  
  515. where filename is the name of this script file (whatever you named the ASCII
  516. text file).  Since there are two separate programs ... COLD.COM and
  517. WARM.COM, you will need to repeat the above instructions once for each area.
  518.  
  519. ----------------------------->CUT HERE<-----------------------------
  520.  N COLD.COM
  521.  E 0100 B8 40 00 8E D8 B8 7F 7F A3 72 00 EA 00 00 FF FF
  522.  RCX
  523.  0010
  524.  W
  525.  Q
  526. ----------------------------->CUT HERE<-----------------------------
  527.  
  528.  ... and the second one ...
  529.  
  530. ----------------------------->CUT HERE<-----------------------------
  531.  N WARM.COM
  532.  E 0100 B8 40 00 8E D8 B8 34 12 A3 72 00 EA 00 00 FF FF
  533.  RCX
  534.  0010
  535.  W
  536.  Q
  537. ----------------------------->CUT HERE<-----------------------------
  538.  
  539. * Richard Dale @ 1:280/333
  540.  
  541. ────────────────────────────────────────────────────────────────────────────
  542.  
  543. Communicating With a Modem
  544. ==========================
  545. -> Added on January 3, 1995
  546.  
  547. A common question is how to communicate with a modem either in a batch file
  548. or on the command-line.  After setting up the COM port with MODE (if it's
  549. required) simply use DOS redirection ">" to ECHO AT commands to the modem.
  550.  
  551.    mode COM1 baud=19200 data=8 parity=n stop=1
  552.    echo AT&FF10\N4&D3E0M0Q1S0=1&W0>COM1
  553.  
  554. The above example might be used to set up a modem loading a profile into it.
  555.  
  556. Or if you wanted to leave a computer accessable from a remote location you
  557. might shell out of a communications program and run a batch file containing:
  558.  
  559.          %COMSPEC% /e:1024 >COM1 <COM1
  560.  
  561. ... which would start a copy of the command processor to accept input from
  562. the remote computer and output to it.  (With MS-DOS, error messages would not
  563. get sent but 4DOS allows STNDERR device writes to be re-directed)
  564.  
  565. * jamie.hermans@tech-spk.alive.ampr.ab.ca
  566.   or FidoNet: Jamie Hermans @ 1:342/707
  567.  
  568. ────────────────────────────────────────────────────────────────────────────
  569.  
  570. Using CTRL+Z in a Batch File
  571. ============================
  572. -> Added on January 3, 1995
  573.  
  574. Normally, whenever you put a Ctrl+Z in a batch file, that is where execution
  575. of the batch stops.  This happens because Ctrl+Z is an End-Of-File Marker for
  576. DOS (EOF).  Using EDLIN in a BATch often needs the Ctrl+Z to be entered into
  577. a script and one of the few ways to do this is from the command prompt.
  578.  
  579.   Type:   SET ZED=(Ctrl+Z)  Replacing the bracketed text with
  580.                              the real key combination.
  581.  
  582. In BATch files thereafter you can use %ZED% where you are required to use a
  583. Control+Z key combination.  Here's a quick example.  This batch will search
  584. README.TXT and replace Microsoft with Mickey$loth.
  585.  
  586.   echo 1,#RMicrosoft%ZED%Mickey$loth>test.scr
  587.   echo e>>test.scr
  588.   edlin README.TXT <test.scr
  589.  
  590. * jamie.hermans@tech-spk.alive.ampr.ab.ca
  591.   or FidoNet: Jamie Hermans @ 1:342/707
  592.  
  593. ────────────────────────────────────────────────────────────────────────────
  594.  
  595. Nested "FOR xxx IN (*.*) DO xxx" Loops
  596. ======================================
  597. -> Added on January 3, 1995
  598.  
  599. Normally, FOR-loops cannot be nested.  If they could, we could say:
  600.  
  601.   for %%f in (h H /?) do for %%g (// -) do if "%1"==(%%g%%f) goto @Help
  602.  
  603. It *is* possible to nest FOR loops, by using COMMAND /C...
  604.  
  605.   for %%f in (h H /?) do command /c for %%g in (// -) do if "%1"==(%%g%%f)...
  606.                                                                 ...goto @Help
  607.  
  608. * Steve Reid @ 1:153/414
  609.  
  610. ────────────────────────────────────────────────────────────────────────────
  611.  
  612. Testing for Command Line Arguments
  613. ==================================
  614. -> Added on January 3, 1995
  615.  
  616. The %PATH% variable is a handy little item.  To enter ...
  617.     set path=c:\bat;c:\dos;c:\util
  618.  
  619. you would end up with ...
  620.     %path%==c:\bat;c:\dos;c:\utl
  621.  
  622. however, to enter ...
  623.     path c:\bat;c:\dos;c:\utl
  624.  
  625. you would end up with ...
  626.     %path%==C:\BAT;C:\DOS;C:\UTL
  627.  
  628.  
  629. Subsequently, in a batch file, you have an obvious "short-cut" ...
  630.  
  631.     [...]
  632.     set oldpath=%path%
  633.     path %1
  634.     set parm1=
  635.     for %%a in (WAHTEVER RANGE YOU LIKE) do if %%a==%path% set parm1=%%a
  636.     path %oldpath%
  637.     set oldpath=
  638.     if (%parm1%)==() goto Invalid_Parm
  639.     [...]
  640.  
  641. Imagine trying to test for all possible combinations of the word RANGE..
  642.   ie.  Range RAnge ranGe ... and so on!
  643.  
  644. * Peter Lovell @ 3:640/302
  645.  
  646. ────────────────────────────────────────────────────────────────────────────
  647.  
  648. Asking for Help
  649. ===============
  650. -> Added on January 3, 1995
  651.  
  652. If you are making your batch file "user friendly", you'll probably want to
  653. supply some kind of help option.  The trouble is, there are many ways of
  654. adding parameters to a command line.  The following example should cover all
  655. possible "help" commands ... /? /H -? H  etc.
  656.  
  657.  
  658.      @echo off
  659.      for %%f in (h H /?) do if "%1"=="-%%f" goto @SyntaxInfo
  660.      for %%f in (h H /?) do if "%1"=="/%%f" goto @SyntaxInfo
  661.      for %%f in (h H /?) do if "%1"=="%%f"  goto @SyntaxInfo
  662.  
  663.      ... Your Batch File Here ...
  664.  
  665.      :SyntaxInfo
  666.      ... Whatever Help You Wish to Provide ...
  667.  
  668.  
  669. Notice the "/?" in the FOR set.  People made me understand the use of the
  670. forward slash in FOR sets, it sends a single character from the string.
  671.  
  672. * Rene Verhagen @ 2:512/250.1243
  673.  
  674. ────────────────────────────────────────────────────────────────────────────
  675.  
  676. Just a Few Tidbits
  677. ==================
  678. -> Added on January 3, 1995
  679.  
  680. After puzzling over a few commonly asked questions, this is the result.  When
  681. compared to other methods they reduce the number of lines required in a batch
  682. file.  Examples using MS-DOS 6.22
  683.  
  684.  
  685. (1) To save starting directory and return to it afterwards ...
  686.  
  687. echo exit|%comspec%/k  PROMPT @$N:$_@CD $P$_>c:\tmp.bat
  688. ::
  689. :: .... batch file commands go here ....
  690. ::
  691. for %%x in (call del) do %%x c:\tmp.bat
  692.  
  693.  
  694. (2) To set day of week in environment variable DOW ...
  695.  
  696. echo exit|%COMSPEC%/K prompt SET DOW$Q$D$E[11D$E[K$_@>c:\tmp.bat
  697. for %%x in (call del) do %%x c:\tmp.bat
  698.  
  699.  
  700. (3) To set time in environment variable TIME ...
  701.  
  702. echo exit|%COMSPEC%/K prompt SET TIME$Q$T$_@>c:\tmp.bat
  703. for %%x in (call del) do %%x c:\tmp.bat
  704.  
  705. * Michael Druett @ 3:771/425
  706.  
  707. ────────────────────────────────────────────────────────────────────────────
  708.  
  709. Getting the Date into Variables
  710. ===============================
  711. -> Added on January 3, 1995
  712.  
  713. Here's something that may be useful to someone. This .BAT will take the date
  714. and put it into the variables YY, MM and DD.  You can then display the date
  715. in whatever format you want.  Uses the "/" MUF of the FOR command.
  716.  
  717. :DATEFORM.BAT by Steve Reid
  718. @if %1.==swr. prompt set date=$d
  719. @if %1.==swr. goto end
  720. @echo off
  721. command /c %0 swr>%temp%\xtempx.bat
  722. call %temp%\xtempx.bat
  723. del %temp%\xtempx.bat
  724. echo %date%
  725. for %%i in (%date%) do set yy=%%i
  726. set var=z
  727. :loop
  728. set var=%var%x
  729. for %%i in (/%yy%) do set date=%%i
  730. for %%i in (/%yy%) do if not %%i.==%date%. set %var%=%%i
  731. set yy=%date%
  732. if not %var%==zxxxxxxxx goto loop
  733. set mm=%zx%%zxx%
  734. set dd=%zxxxx%%zxxxxx%
  735. for %%i in (var date zx zxx zxxx zxxxx zxxxxx) do set %%i=
  736. for %%i in (zxxxxxx zxxxxxx zxxxxxxx zxxxxxxxx) do set %%i=
  737. echo %yy%%mm%%dd%
  738. :end
  739.  
  740. It uses a significant amount of environment space, but it still works with a
  741. 256 byte environment if most of it is free, probably doesn't even need that
  742. much.
  743.  
  744. * sreid@sea-to-sky-freenet.bc.ca
  745.   or FidoNet: Steve Reid @ 1:153/414
  746.  
  747. ────────────────────────────────────────────────────────────────────────────
  748.  
  749. Need the Time and Date?
  750. =======================
  751. -> Added on January 3, 1995
  752.  
  753. Add the following lines to any batch file to get the current date & time.
  754.  
  755.     @ECHO OFF
  756.     ECHO | MORE | TIME | FIND /V "new"
  757.     ECHO | MORE | DATE | FIND /V "new"
  758.  
  759. * jamie.hermans@tech-spk.alive.ampr.ab.ca
  760.   or FidoNet: Jamie Hermans @ 1:342/707
  761.  
  762. ────────────────────────────────────────────────────────────────────────────
  763.  
  764. Additional Environment Variable Space
  765. =====================================
  766. -> Added on December 12, 1994
  767.  
  768. This is a guaranteed method of creating a larger default environment variable
  769. space for EACH copy of COMMAND.COM that is loaded.  Some people may
  770. experience an out of environment error when running batch files from another
  771. program.  This is a sure fix, but also a permanent one!  When a new version
  772. of MS-DOS comes out, this fix will cause the update program to abort.  Make
  773. sure you have a back-up copy of the original for when this time comes.
  774.  
  775. This example is specific to MS-DOS version 6.22 COMMAND.COM of 54,645 bytes.
  776. The date and time of the file should be May 31, 1994 at 6:22am respectively.
  777. See the end of this section for instructions for finding patch points in
  778. different versions of COMMAND.COM
  779.  
  780. @echo off
  781. :: THIS ONLY WORKS FOR ...  COMMAND.COM 54,645 05-31-94   6:22a
  782. :: make changes to "C:" and "CD\DOS" as needed in the next two lines
  783. c:
  784. cd\dos
  785. if exist command.pat echo It seems you have already patched this version!
  786. echo.
  787. if exist command.pat type command.pat
  788. if exist command.pat goto end
  789. copy command.com command.256 >nul
  790. echo Patched COMMAND.COM on date shown on next line:>command.pat
  791. ver|date|find "Curr">>command.pat
  792. echo e1777 40>>command.pat
  793. echo w>>command.pat
  794. echo q>>command.pat
  795. attrib -r -h -s command.com
  796. debug command.com <command.pat
  797. echo.
  798. echo Done.  COMMAND.COM now patched for default 1024-byte env.
  799. echo Original saved as COMMAND.256  (256-byte env.)
  800. :end
  801.  
  802. P.S.: the patch points for other versions are circulating in a file called
  803. (I think) ENVPATCH.ZIP; it may be in BFDS.  The string to look for (for
  804. example, using Buerg's List in hex mode):
  805.  
  806.      LIST.COM COMMAND.COM /H
  807.  
  808. is  001670  21 5A 00 C7 06 8D 21 40 00 BA A4 AF B1 04 D3 EA
  809.  
  810. Note the "8D 21 40 00" which is "8D 21 10 00" in the unpatched COMMAND.COM
  811. Also note that when using DEBUG, the address as reported by LIST must be
  812. bumped up by hex 0100, from 001677 to 001777.  For 512-byte environment, use
  813. 20 instead of 40.
  814.  
  815. Good luck!  DO NOT PATCH YOUR ONLY COPY of COMMAND.COM <GRIN>
  816.  
  817. * Gerry Pareja @ 1:153/151
  818.  
  819. ────────────────────────────────────────────────────────────────────────────
  820.  
  821. Patch Points in COMMAND.COM
  822. ===========================
  823. -> Added on December 12, 1994
  824.  
  825. If you like the idea of being able to patch COMMAND.COM, but you don't have
  826. the version used above ... here's the various addresses for this patch in the
  827. various versions of MS-DOS.
  828.  
  829. Ver           Date     Time      Size     Offset    Default Size
  830. ---------------------------------------------------------------------
  831. MS-DOS 3.30   02-02-88 12:00am   25038    0DB8h     0Ah  (160 bytes)
  832. PC-DOS 3.30   03-17-87 12:00pm   25307    0DB8h     0Ah  (160 bytes)
  833.  
  834. MS-DOS 4.01   12-19-88 12:00am   37557    1B2Ah     0Ah  (160 bytes)
  835.  
  836. MS-DOS 5.00   04-09-91  5:00am   47845    1566h     10h  (256 bytes)
  837. MS-DOS 5.00   03-22-91  5:10am   47845    1566h     10h  (256 bytes)
  838.  
  839. MS-DOS 6.00   03-10-93  6:00am   52925    1667h     10h  (256 bytes)
  840.  
  841. MS-DOS 6.20   09-30-93  ?:???m   ?????    1677h     10h  (256 bytes)
  842. MS-DOS 6.22   ??-??-??  ?:???m   ?????    1677h     10h  (256 bytes)
  843.  
  844.  
  845. (Add 100h to the >offset< if using DEBUG to patch COMMAND.COM)
  846. ( See sample instructions below patching MS-DOS 5.0          )
  847.  
  848. For those unfamiliar with patching, make sure you have a boot floppy
  849. available in case of an error.  Copy COMMAND.COM to something like
  850. COMMAND.ORG. Then, at the Dos prompt, if you want a 384 byte environment,
  851. type:
  852.  
  853.    DEBUG COMMAND.COM    <-- you will see a "-" prompt. Type:
  854.    E 1666 18            <-- followed by Enter
  855.    W                    <-- followed by Enter. You will see "Writing.." etc
  856.    Q                    <-- which exits DEBUG
  857.  
  858.          Various environment size values:
  859.      01h =   16 bytes              40h = 1024 bytes
  860.      10h =  256 bytes (default)    60h = 1536 bytes
  861.      20h =  512 bytes              80h = 2048 bytes
  862.      30h =  768 bytes              FFh = 4080 bytes
  863.  
  864. * Jeff Brielmaier @ 1:106/4100
  865.  
  866. ────────────────────────────────────────────────────────────────────────────
  867.  
  868. Freeing up Environemt Space
  869. ===========================
  870. -> Added on December 12, 1994
  871.  
  872. In Autoexec.bat, add the line:
  873.  
  874.      set dummy=1234567890123456789012345678901234567890
  875.  
  876. ... (or longer if you wish) then, in _every_ batch file that is run in a
  877. shell, release that variable by using:
  878.  
  879.      set dummy=
  880.  
  881. which immediately releases 50 or more bytes to the current environment.
  882.  
  883. * Gerry Pareja @ 1:153/151
  884.  
  885. ────────────────────────────────────────────────────────────────────────────
  886.  
  887. Changing an ErrorLevel into a Variable
  888. ======================================
  889. -> Added on December 12, 1994
  890.  
  891. Is there any way to echo an errorlevel?  There're several batch methods
  892. around which will accomplish this.  Here's the one I use:
  893.  
  894. @echo off
  895. for %%x in (0 1 2) do if errorlevel %%x00 set el=%%x
  896. if not %el%==2 goto not200
  897. for %%x in (0 1 2 3 4 5) do if errorlevel %el%%%x0 set el=%el%%%x
  898. if not %el%==25 goto not250
  899. for %%x in (0 1 2 3 4 5) do if errorlevel %el%%%x set el=%el%%%x
  900. goto done
  901.  
  902. :not200
  903. for %%x in (0 1 2 3 4 5 6 7 8 9) do if errorlevel %el%%%x0 set el=%el%%%x
  904.  
  905. :not250
  906. for %%x in (0 1 2 3 4 5 6 7 8 9) do if errorlevel %el%%%x set el=%el%%%x
  907.  
  908. :done
  909. echo Errorlevel is %el%
  910.  
  911.  
  912. It sets a three digit environment variable called EL to the current value of
  913. the errorlevel, left padded with zeroes.
  914.  
  915. Here's a little programme to test it with. I believe it was written by John
  916. Gray. SEL.ZIP contains SETEL.COM, which can be used to set an errorlevel. The
  917. syntax is simply SETEL 99 (to set the errorlevel to 99).
  918.  
  919. To use the following program, you'll need to save everything between the two
  920. --->CUT HERE<--- lines *EXACTLY* as you see here, into a plain ASCII text
  921. file.  Once that's done, at the DOS prompt, type
  922.  
  923.     DEBUG < filename
  924.  
  925. where filename is the name of this script file (whatever you named the ASCII
  926. text file).
  927.  
  928. ----------------------------->CUT HERE<-----------------------------
  929.  NSEL.ZIP
  930.  E100 FC BB 03 00 BF D4 01 BE CC 01 33 C9 AD 86 CC AA FE C0 E2 FB 4B
  931.  E115 75 F5 B9 FF FD BA 20 02 52 B4 3F CD 21 5F 72 60 8B F7 50 8B C8
  932.  E12A B0 2A F2 AE 75 55 B0 0D F2 AE 87 F7 BB 00 01 B2 04 AC 3C 2A 72
  933.  E13F 62 74 46 57 BF D2 01 B9 40 00 8A E1 F2 AE 5F 75 35 FE C1 2A E1
  934.  E154 88 27 43 FE CA 75 E0 56 BE 00 01 AD 86 C4 8B D0 AD 86 C4 5E B1
  935.  E169 02 D2 E0 D3 E0 D2 E2 D3 EA D0 E1 D1 EA D1 D8 E2 FA 86 C2 AA 8A
  936.  E17E C4 AA 8A C2 AA EB B1 BF 20 02 58 33 D2 F7 D8 13 D2 F7 DA 33 DB
  937.  E193 8B CA 8B D0 B8 01 42 CD 21 8B 0E CA 01 CC AC 3C 0A 75 FB AC 57
  938.  E1A8 BF D2 01 B9 40 00 8A E1 F2 AE 5F 75 D0 FE C1 2A E1 86 E0 32 E4
  939.  E1BD 8B 1E CA 01 03 D8 89 1E CA 01 E9 6C FF 00 00 30 0A 41 1A 61 1A
  940.  E1D2 2B 2D
  941.  G=100
  942.  W220
  943.  Q GXDPlus 1.0
  944. *XXBUG20--00000198--27111994--BD201A56------------------SEL.ZIP
  945. nI2g1--E++++6++eaRljKgDjI7+2++4k-+++7++++IoJIFIkiEoxBJMwlGwBE36IX046Y
  946. nWsjf3FlOf-c85GfR72UZK6WGzNZQYkTBSy4y3oEF4hnOeNiCzcUWcdAzE5-o3b5k-nVo
  947. noNQWK8Q1VyyQQyxhOLIgjRBN54nS17yuXtMpT9qnFxRLJXZp9xT8OLikKbuuLlyoMfrE
  948. nohvPywFzLbzc9YmKXNEniTwqpd3rv+JyuAAiN3kd9V8E-3l2YUUX1JsEx+9T0noTQYMg
  949. nEsrYq-hnAJbcjDU58hGU7HFP9ICClrCgHfa0b4FWaWdA4ETbcnJrmwHeQ2cm+wRaI3rI
  950. nlvzh-dmZD2cV8tG42kEdgBfG8G40816Y5dZUn-BiqfaM1F+H0M9vSlHIygXWuhA978a+
  951. nFF5a4iDuhaATm3H+Df5n-fWhkpvMPXfq1p-9+E6I+-E++++6++eaRljKgDjI7+2++4k-
  952. n+++7++++++++++2+6+++++++++-HFJF3H0t1HopEGkI4++++++2++E+r++++Gk2+++++
  953. *XXBUG Version 2.20 by Chad Wagner
  954. ----------------------------->CUT HERE<-----------------------------
  955.  
  956. * John Evans @ 2:2433/506
  957.  
  958. ────────────────────────────────────────────────────────────────────────────
  959.  
  960. ANSI Control Codes
  961. ==================
  962. -> Added on December 12, 1994
  963.  
  964. An ANSI control code can do lots of things.  Each ANSI code has the same
  965. basic format.  First is the escape command.  We will show it as ESC in this
  966. text.  In an ASCII editor, it can be entered into a batch file by typing 027
  967. while holding the ALT key down.  Next is the "[" character.  Then the
  968. parameters.  Be sure to pay attention to upper and lower case letters in the
  969. parameters.
  970.  
  971.   ESC[2J           - To clear the screen and home the cursor
  972.   ESC[#;*H         - To locate the cursor to row #, column, *
  973.   ESC[#A           - To move the cursor    up # rows
  974.   ESC[#B           - To move the cursor  down # rows
  975.   ESC[#C           - To move the cursor right # columns
  976.   ESC[#D           - To move the cursor  left # columns
  977.   ESC[s            - To store the current cursor position
  978.   ESC[u            - To return to the stored cursor position
  979.  
  980.   ESC[#;...;#m     - To set a color and attribute use #;...;# which is a list
  981.                       of attributes.  Replace # IN ESC[#;...;#m with the
  982.                       value for the desired attribute, separating multiple
  983.                       parameters with a semi-colon.
  984.  
  985. The ;# sequence sets the colour according to the following table:
  986.  
  987.  Fore   Back       Colour
  988.   30     40        - Black
  989.   31     41        - Red
  990.   32     42        - Green
  991.   33     43        - Yellow
  992.   34     44        - Blue
  993.   35     45        - Magenta
  994.   36     46        - Cyan
  995.   37     47        - White
  996.  
  997. The ;#m sequence sets the attribute according to the following table:
  998.  
  999.   0                - All attributes off (normal white-on-black)
  1000.   1                - Bold on (high intensity)
  1001.   4                - Underscore on (monochrome display only)
  1002.   5                - Blink on
  1003.   7                - Reverse video on
  1004.   8                - Cancelled on (invisible, not demonstrated)
  1005.  
  1006. The ESC[=#h sequence sets screen modes according to the following table:
  1007.  
  1008.   0                - 40x25 black & white
  1009.   1                - 40x25 color
  1010.   2                - 80x25 black & white
  1011.   3                - 80x25 color
  1012.   4                - 320x200 color
  1013.   5                - 320x200 black & white
  1014.   6                - 640x200 black & white
  1015.   7                - Line Wrap On (typing beyond end of line starts new line)
  1016.  
  1017. ANSI codes can be used by adding them to the text you send to the display
  1018. with the ECHO command.  For example, a blinking yellow on blue HELLO can be
  1019. obtained with the line:
  1020.  
  1021.  "ESC[33;44;1;5mHELLOESC[0m"
  1022.  
  1023. * Unknown Source - Sorry!
  1024.  
  1025. ────────────────────────────────────────────────────────────────────────────
  1026.  
  1027. Let X=X+1 ?!?
  1028. =============
  1029. -> Added on December 12, 1994
  1030.  
  1031. Pure MS-DOS won't allow math evaluation.  N/4DOS will or some other utility
  1032. may allow you to do a calculation, but here is a batch file to let you do
  1033. JUST that.  Enjoy!!
  1034.  
  1035. @echo off
  1036. ::
  1037. :: REPEAT.BAT -- by R.Neve, released into the Public Domain 26/11/94
  1038. ::
  1039. :: Needs DEBUG.EXE and FIND.EXE in the path
  1040. :: Syntax: REPEAT {n} {c1 [, c2, c3, ..., c8]}
  1041. :: where : - {n} is the number of iterations, expressed using the following
  1042. ::               formula: 2n+14 (n=number of iterations), for example, let's
  1043. ::               you wanted to run repeat 20 times, you'd write: 2*20+14=54
  1044. ::         - {c1 [, c2, c3, ..., c8]} is the command using up to 8 elements
  1045. ::               which you want to repeat the specified number of times.
  1046. ::               It can be any valid dos command or program with params, but
  1047. ::               only the first 8 elements are taken into account
  1048. ::
  1049. :: Ex: Do a 'DIR' five times (very useful!!):
  1050. ::
  1051. ::     REPEAT 24 dir c:\ /-p
  1052. ::            |  ^^^^^^^^^^^- command to repeat 5 times.
  1053. ::            |
  1054. ::            +- 5*2+14=24
  1055. ::
  1056. if '%1'=='' goto syntax
  1057. echo r cx > debug.scr
  1058. echo 5>> debug.scr
  1059. echo w>> debug.scr
  1060. echo q>> debug.scr
  1061. echo @set size=%%2>#2.bat
  1062.  
  1063. :do_command
  1064. echo call >#1.bat
  1065. debug #1.bat < debug.scr > nul
  1066. if '%size%'=='%1' goto end
  1067. echo.>>#2.bat
  1068. %2 %3 %4 %5 %6 %7 %8 %9
  1069. dir /-p #2.bat|find /i "#2"|find /i "bat" >> #1.bat
  1070. call #1
  1071. goto do_command
  1072.  
  1073. :syntax
  1074. echo REPEAT ■ Sept'94 - R.Neve
  1075. echo ═════════════════════════
  1076. echo Syntax: REPEAT {n} {c1 [, c2, c3, .., c8]}
  1077. echo where : {n} is number of iterations*2+14
  1078. echo         ex: for 30 iterations, enter 30*2+14=74
  1079. echo         {c1 ...} is a commands (up to 8 elements) to execute
  1080. echo         the specified number of times
  1081. echo.
  1082. goto quit
  1083.  
  1084. :end
  1085. for %%a in (#1.bat #2.bat debug.scr) do del %%a
  1086. set size=
  1087.  
  1088. :quit
  1089. cls
  1090.  
  1091. * Raphael Neve @ 2:321/1
  1092.  
  1093. ────────────────────────────────────────────────────────────────────────────
  1094.  
  1095. Saving the Current Directory - Part 1
  1096. =====================================
  1097. -> Added on December 12, 1994
  1098.  
  1099. Paste the following three lines into your batch file at any stage where you
  1100. are at the drive:\dir you'd like to return to.
  1101.  
  1102.     echo @prompt @echo off$_$n:$_cd $p>%temp%\temp.bat
  1103.     %comspec% /c %temp%\temp>c:\bat\pop.bat
  1104.     del %temp%\temp.bat
  1105.  
  1106. Then later in your batch file, when you'd like to pop back to where you were,
  1107. simply past in the following line.
  1108.  
  1109.     call c:\bat\pop
  1110.  
  1111. * Peter Lovell @ 3:640/302
  1112.  
  1113. ────────────────────────────────────────────────────────────────────────────
  1114.  
  1115. Saving the Current Directory - Part 2
  1116. =====================================
  1117. -> Added on December 12, 1994
  1118.  
  1119. Thanks to Gerry Pareja who taught me how to redirect the command prompt to
  1120. accomplish tricks in batch files.  You can customize your command prompt to
  1121. include information about the current drive, directory, time, date, ">", "<",
  1122. "|", "=", etc.  The idea is to create a "magic prompt" that reads like a
  1123. batch file, then get it into a batch file.  And it doesn't even change your
  1124. "real" prompt!  It takes three steps.
  1125.  
  1126. STEP 1:
  1127.  
  1128.   echo @prompt PromptString > temp1.bat
  1129.  
  1130.      Now temp1.bat has one line, a prompt command.  Pick the PromptString to
  1131.      write the "magic prompt" that you need.  Some examples and the prompt
  1132.      they create are:
  1133.  
  1134.      @prompt $n:$_CD $p            D:
  1135.                                    CD D:\BBS\BWAVE
  1136.  
  1137.      @prompt SET CURR$Q$p          SET CURR=D:\BBS\BWAVE
  1138.  
  1139.      You might want to issue these prompt commands interactively (without @)
  1140.      to better understand how this works.
  1141.  
  1142. STEP 2:
  1143.  
  1144.   command /C temp1.bat > temp2.bat
  1145.  
  1146.      Now temp2.bat has 2 or more lines.  The first line is blank.  The other
  1147.      lines contain the magic prompt we composed in step one.  We have turned
  1148.      the prompt into a real batch file!
  1149.  
  1150. STEP 3:
  1151.  
  1152.   call temp2.bat
  1153.  
  1154.      This uses the batch file.
  1155.  
  1156. Notes:
  1157.   For a complete implementation you may want to erase the work files.  For
  1158.   speed you might put the work files onto a RAM disk.  For some purposes you
  1159.   might want to insert additional work between steps two and three.  If those
  1160.   additional steps change the current directory, then you need to know where
  1161.   "temp2.bat" was created - perhaps as %TEMP%\temp2.bat.
  1162.  
  1163. * William Lipp @ 1:141/1295
  1164.  
  1165. ────────────────────────────────────────────────────────────────────────────
  1166.  
  1167. Naming Batch Files
  1168. ==================
  1169. -> Added on December 7, 1994
  1170.  
  1171. A batch file can have any legal DOS filename as long as it ends in .BAT and
  1172. doesn't conflict with other similar filenames or commands in your system.
  1173. When it sees files with similar names, DOS will always execute the ones that
  1174. end in .COM and .EXE before it runs one ending in .BAT
  1175.  
  1176. Unless you get tricky, you can't have DOS run batch files with names similar
  1177. to "internal" DOS commands.  Internal commands are the ones actually
  1178. contained inside the main COMMAND.COM file (PROMPT, DIR, CALL, CHCP, RENAME,
  1179. REN, ERASE, DEL, TYPE, REM, COPY, PAUSE, DATE, TIME, VER, VOL, CD, CHDIR,
  1180. MD, MKDIR, RD, RMDIR, BREAK, VERIFY, SET, PATH, EXIT, CTTY, ECHO, GOTO,
  1181. SHIFT, IF, FOR, CLS, LOADHIGH, LH, OR TRUENAME).  Starting with Version 5.0
  1182. of MS-DOS, DOS will also run DOSKEY macros before batch files with similar
  1183. names ... It's tough being a batch file!
  1184.  
  1185. Try to keep the names short, easy to remember, and easy to type.  The
  1186. eight-character name limitation can be vexing, especially for a long batch
  1187. file that does something complex, but try your best.  These things are
  1188. supposed to make life easier, not more difficult.
  1189.  
  1190. * PC Computing - DOS Power Tools from Paul Somerson
  1191.  
  1192. ────────────────────────────────────────────────────────────────────────────
  1193.  
  1194. Quick Tour
  1195. ==========
  1196. -> Added on December 7, 1994
  1197.  
  1198. Technically, DOS provides just eight basic batch file commands -- CALL,
  1199. ECHO, FOR, GOTO, IF, PAUSE, REM, and SHIFT -- plus a tiny assortment of
  1200. miscellaneous doodads: replaceable parameters, environment variables,
  1201. labels, double == signs, and @ signs.  That's it!  Not too much to learn,
  1202. even for the most fervent DOS-hater.  But the tools these few commands can
  1203. create will astonish you.
  1204.  
  1205. The quickest way to learn the "doings" and syntax for each of the commands
  1206. is too use MS-DOS's HELP program.  Want to check out CALL?  Type either
  1207.  
  1208.     CALL /?   or   HELP CALL
  1209.  
  1210. at the prompt and DOSS will display either a few lines of help (CALL /?) or
  1211. open up it's reference database (HELP CALL) with examples and usage syntax.
  1212.  
  1213. * PC Computing - DOS Power Tools from Paul Somerson
  1214.  
  1215. ────────────────────────────────────────────────────────────────────────────
  1216.  
  1217. Environment Variables
  1218. =====================
  1219. -> Added on December 7, 1994
  1220.  
  1221. The DOS SET commands gives you and your batch file access to a special area
  1222. of memory called the DOS environment.  DOS normally uses the environment as
  1223. the place to store its own important settings for your PATH, PROMPT, and
  1224. COMSPEC.
  1225.  
  1226. Typing SET all by itself will show you the current values of these three
  1227. settings, plus settings for anything else that has been defined in the
  1228. environment.  If you will be using the environment for your own variables
  1229. (covered later on in this text), you should increase the space allocated by
  1230. CONFIG.SYS.  Use the command
  1231.  
  1232.     SHELL=C:\DOS\COMMAND.COM C:\DOS\ /E:1024 /P
  1233.  
  1234. in your CONFIG.SYS to boost the default to 1024 bytes.
  1235.  
  1236. Once you've given yourself some environment elbow room, you can use it to
  1237. store your own variables.  You can put variables in there, either directly
  1238. at the DOS prompt, or from inside batch files, by using the SET command.  To
  1239. create a variable called MAG and give it a value of PCC you would type
  1240.  
  1241.     SET MAG=PCC
  1242.  
  1243. DOS automatically capitalizes the environment names themselves (in this
  1244. case, the name is MAG), but not the values themselves.  Therefore, the above
  1245. command is the same as typing
  1246.  
  1247.     set mag=PCC
  1248.  
  1249. However; if you typed
  1250.  
  1251.     SET MAG2=pcc
  1252.  
  1253. the value of MAG2 would be lowercase pcc.  Once you set an environment
  1254. variable like MAG, you can change the setting by simply using the SET MAG=
  1255. command again.  Each successive SET MAG command wipes out the previous one.
  1256. Remember, you can always see the current settings by typing SET at the DOS
  1257. prompt.
  1258.  
  1259. To erase any setting, type SET followed by the variable name and an equal
  1260. sign with nothing after it.  To remove the MAG variable and it's current
  1261. value from the environment, type
  1262.  
  1263.     SET MAG=
  1264.  
  1265. Because space is limited, it's always a good idea to have your batch files
  1266. clean up after themselves by removing all variables if they are not needed
  1267. later.
  1268.  
  1269. * PC Computing - DOS Power Tools from Paul Somerson
  1270.  
  1271. ────────────────────────────────────────────────────────────────────────────
  1272.