home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / TEXT / N7TIPS.ZIP / 1014118.TXT < prev    next >
Text File  |  1994-03-04  |  26KB  |  763 lines

  1.  
  2.  
  3.               NOVELL TECHNICAL INFORMATION DOCUMENT
  4.  
  5. TITLE:              Sample Configuration and Batch Processing Files
  6. DOCUMENT ID:        014918
  7. DOCUMENT REVISION:  A
  8. DATE:               27FEB94
  9. ALERT STATUS:       Yellow
  10. INFORMATION TYPE:   Issue
  11. README FOR:         NA
  12.  
  13. NOVELL PRODUCT and VERSION:
  14. Novell DOS 7
  15.  
  16. ABSTRACT:
  17.  
  18. This document offers users an idea of the possible enhancements
  19. that can be made to system configuration and batch files, using
  20. the tools available in Novell DOS 7.
  21.  
  22. ------------------------------------------------------------------
  23. DISCLAIMER
  24. THE ORIGIN OF THIS INFORMATION MAY BE INTERNAL OR EXTERNAL TO
  25. NOVELL.  NOVELL MAKES EVERY EFFORT WITHIN ITS MEANS TO VERIFY
  26. THIS INFORMATION.  HOWEVER, THE INFORMATION PROVIDED IN THIS
  27. DOCUMENT IS FOR YOUR INFORMATION ONLY.  NOVELL MAKES NO EXPLICIT
  28. OR IMPLIED CLAIMS TO THE VALIDITY OF THIS INFORMATION.
  29. ------------------------------------------------------------------
  30.  
  31. ISSUE
  32.  
  33.      NOVELL DOS 7 has greatly enhanced CONFIG and BATCH commands.
  34.      This document provides examples of how these various
  35.      commands can be used.  For more information on batch file
  36.      commands and syntax refer to DOSBOOK, the NOVELL DOS 7
  37.      online User Guide.  Also reading the following chapters from
  38.      DOSBOOK would be particularly helpful:
  39.  
  40.           Chapter 7, "Batch Processing"
  41.           Chapter 8, "Command Reference"
  42.           Chapter 9, "Configuring the System"
  43.  
  44.      Batch commands that were added since DR DOS 6.0 are the
  45.      following:
  46.  
  47.      ?         Allows a yes or no branch in the same manner as
  48.                the "?" in the DR DOS 6.0 CONFIG.SYS command.
  49.  
  50.      DIREXIST  Added to evaluate whether a directory exists.
  51.  
  52.      CHOICE    Returns an error level for evaluation.
  53.  
  54.      Only the basic ideas are outlined in each example that
  55.      follows.  A batch file that illustrates the new NOVELL DOS 7
  56.      commands and their use is at the end of this document.
  57.  
  58.  
  59.      EXAMPLE 1 - THE USE OF GOTO IN THE CONFIG.SYS FILE
  60.  
  61.      ?"Do you want to run QEMM (y/n)? " goto QEMM
  62.      ?"Do you want to run MemoryMAX (y/n)? " goto NWDOS
  63.  
  64.  
  65.      :QEMM
  66.      DEVICE=C:\QTR_DECK\QEMM386.SYS
  67.      DEVICE=C:\NWDOS\HIMEM.SYS
  68.      (additional QEMM driver lines go here...)
  69.      goto COMMON
  70.  
  71.      :NWDOS
  72.      DOS=UMB
  73.      DEVICE=C:\NWDOS\EMM386.EXE /F=AUTO...
  74.      ...
  75.  
  76.      :COMMON
  77.      files=40
  78.      buffers=20
  79.  
  80.      The GOTO statement is used to proceed directly to a label. 
  81.      This function works similar to the GOTO statement found in
  82.      batch file processing.
  83.  
  84.  
  85.      EXAMPLE 2 - THE USE OF CHAIN IN THE CONFIG.SYS FILE
  86.  
  87.      This example shows that you can link to other files that
  88.      hold your configurations for each system setup.  In the
  89.      following CONFIG.SYS file, the two lines direct the
  90.      configuration process to the QCONFIG and MCONFIG.SYS files. 
  91.      The appropriate FILES, BUFFERS, and so forth, information is
  92.      contained within those files and not within the main
  93.      CONFIG.SYS file.  If the response to both questions is no, a
  94.      default configuration begins.  The RETURN command cannot be
  95.      used to return to the parent CONFIG.SYS file.
  96.  
  97.      ?"Do you want to run QEMM (y/n)? " chain=QCONFIG.SYS
  98.      ?"Do you want to run MemoryMAX (y/n)? " chain=MCONFIG.SYS
  99.      files=40
  100.      buffers=20
  101.  
  102.  
  103.      EXAMPLE 3 - USING "?" IN BATCH FILES
  104.  
  105.      When you run a batch file containing a "?" statement, a
  106.      response to the prompt is required by the user before
  107.      processing continues.
  108.  
  109.      Please note that the maximum length of a batch file
  110.      statement (including the ?) is 128 characters.
  111.  
  112.      The following statement in a batch file causes the system to
  113.      prompt the user before deleting all the files with the
  114.      extension .OLD from C:\ACCOUNTS:
  115.  
  116.      ?DEL C:\ACCOUNTS\*.OLD
  117.  
  118.      So, when the file executes, the user sees the following
  119.      prompt:
  120.  
  121.      DEL C:\ACCOUNTS\*.OLD (Y/N) ?
  122.  
  123.      If the user answers Y, the DEL command is run and the files
  124.      are deleted.  If the user answers N, the command is ignored
  125.      and the next line in the batch file is processed.
  126.  
  127.      EXAMPLE 4 - USING SWITCH/RETURN AND LABELS
  128.  
  129.      Processing pauses on the SWITCH command until an option is
  130.      chosen.  The appropriate option is selected by choosing a
  131.      number.  The SWITCH command then goes to the corresponding
  132.      label.  In the following example, 1 selects the label :XMS,
  133.      2 selects the label :EMS, and so forth. The RETURN command
  134.      will return processing to the line after SWITCH.  Notice the
  135.      use of the ECHO statement for setting up the menu options.
  136.  
  137.      ECHO =        Choose which Memory you want and how to use it
  138.      ECHO =
  139.      ECHO =          1 (or ENTER)    XMS Memory
  140.      ECHO =          2               EMS Memory
  141.      ECHO =          3               DPMI ON, XMS
  142.      ECHO =          4               DPMI ON, EMS
  143.      ECHO =
  144.      ECHO =         Make your selection...
  145.  
  146.      SWITCH XMS, EMS, DPMI_ON1, DPMI_ON2
  147.      GOTO DEFAULTS
  148.  
  149.      :XMS
  150.      DEVICE=C:\NWDOS\EMM386.EXE /F=NONE /R=AUTO
  151.      RETURN
  152.  
  153.      :EMS
  154.      DEVICE=C:\NWDOS\EMM386.EXE /F=AUTO /R=AUTO
  155.      RETURN
  156.  
  157.      :DPMI_ON1
  158.      DEVICE=C:\NWDOS\EMM386.EXE /F=NONE /R=AUTO /DPMI=ON
  159.      RETURN
  160.  
  161.      :DPMI_ON2
  162.      DEVICE=C:\NWDOS\EMM386.EXE /F=AUTO /R=AUTO /DPMI=ON
  163.      RETURN
  164.  
  165.      :DEFAULTS
  166.      SHELL=C:\COMMAND.COM \C: /P /E:512
  167.      BUFFERS=20
  168.      FILES=30
  169.      DEVICEHIGH=C:\NWDOS\DPMS.EXE
  170.      etc...
  171.  
  172.  
  173.      EXAMPLE 5 - HOW TO USE ENVIRONMENT VARIABLES IN THE
  174.      CONFIG.SYS
  175.  
  176.      The use of variables in the CONFIG.SYS file is not quite the
  177.      same as in batch files.  Because the command processor
  178.      (COMMAND.COM) is not loaded until after the command in the
  179.      CONFIG.SYS file have been processed, the environment
  180.      variables are only stored.  These variables are then passed
  181.      to the command processor, where they can be tested and
  182.      processed through the AUTOEXEC.BAT file or other batch
  183.      files.  Testing an environment variable is not possible in
  184.      the CONFIG.SYS file.  The CLS, CPOS, EXIT and SET commands
  185.      are featured in this example:
  186.  
  187.  
  188.      :DEFAULTS
  189.      SHELL=C:\COMMAND.COM \C: /P /E:512
  190.      BUFFERS=20
  191.      FILES=30
  192.      etc....
  193.  
  194.      ECHO = Choose which TSRs and Utilities you want loaded at
  195.      BOOT
  196.      ECHO = time for this session.
  197.      ECHO =
  198.      ECHO =         1 (or ENTER)   None... just continue
  199.      ECHO =         2              Mouse & Cursor Drivers
  200.      ECHO =         3              Keyboard "Speeder"
  201.      ECHO =         4              Novell Network
  202.      ECHO =         5              Done with selections
  203.      ECHO =
  204.      ECHO =         Make your selection...
  205.  
  206.      :MORE
  207.      CPOS 10,33
  208.      SWITCH NOTHING, CURSMOUS, SPEEDKEY, NOVELL, DONE
  209.      GOTO MORE
  210.  
  211.      :NOTHING
  212.      :DONE
  213.      CLS
  214.      EXIT
  215.  
  216.      :CURSMOUS
  217.      SET THINGS=ON
  218.      RETURN
  219.  
  220.      :SPEEDKEY
  221.      SET SPEEDKEY=ON
  222.      RETURN
  223.  
  224.      :NOVELL
  225.      SET NETWORK=ON
  226.      RETURN
  227.  
  228.      The AUTOEXEC.BAT file now allows testing of the environment
  229.      variables and executes commands based upon the conditionals
  230.      illustrated below:
  231.  
  232.      @ECHO OFF
  233.      VERIFY OFF
  234.      PATH C:\;C:\NWDOS;C:\BATS;C:\TOOLS;C:\WINDOWS
  235.      if "%things%"=="on" prompt
  236.        $e[s$e[0;70H$e[1;36m$t$e[u$e[1;36mDRDOS6$p$g$e[2;32m
  237.      if not "%things%"=="on" PROMPT [NOVELL DOS 7] $P$G
  238.      SET TEMP=C:\TEMP
  239.      IF NOT "%TEMP%"=="" MD %TEMP% >NUL
  240.      if "%things%"=="on" LH MOUSE
  241.      if "%things%"=="on" LH CURSOR /s10
  242.      if "%speedkey%"=="on" c:\nwdos\mode con:rate=30 delay=1
  243.      if "%network%"=="on" LH c:\lan\ipx
  244.      if "%network%"=="on" LH c:\lan\net3
  245.  
  246.  
  247.  
  248.      EXAMPLE 6 - THE CHOICE COMMAND IN BATCH FILES
  249.  
  250.      The CHOICE command is an external program that returns an
  251.      ERRORLEVEL for certain preselected keys.  They can then be
  252.      tested with IF to make branches in a batch file.  Up to 99
  253.      different errors can be returned.  Three lines were used to
  254.      create this example:
  255.  
  256.      CHOICE /C:XY Select X or Y for a message ...
  257.      CLS
  258.      IF ERRORLEVEL 2 ECHO MESSAGE: CHOICE RETURNED AN ERRORLEVEL
  259.      OF 2
  260.      IF ERRORLEVEL 1 ECHO MESSAGE: CHOICE RETURNED AN ERRORLEVEL
  261.      OF 1
  262.  
  263.      The switch /C:XY instructs choice to use the keys X and Y. 
  264.      They are not case sensitive.  The letter X will be
  265.      errorlevel 1 and Y will be errorlevel 2.
  266.  
  267.      The remaining text is the displayed message.   Because you
  268.      chose the letter Y you actually received two messages.  This
  269.      points out one of the tricks to using ERRORLEVEL.  When the
  270.      ERRORLEVEL is tested, a logic is used that considers the
  271.      statement to be true if the value is equal to or greater
  272.      than the returned error.
  273.  
  274.      In the example used here:  ERRORLEVEL=2 (letter Y), is true
  275.      so the message is displayed.  The second statement IF
  276.      ERRORLEVEL 1 is also true (because the returned value of 2
  277.      is greater than or equal to 1) so the message is displayed.
  278.  
  279.      You should always perform the IF tests beginning with the
  280.      highest ERRORLEVEL first.  This is because the IF evaluates
  281.      the statement based on whether the returned value is equal
  282.      or greater than the IF statement.
  283.  
  284.      In the example used here:  ERRORLEVEL=1 (letter X).  The
  285.      first statement IF ERRORLEVEL 2 is FALSE, so the message is
  286.      not displayed.  The second statement IF ERRORLEVEL 1 is true
  287.      so the message is displayed.
  288.  
  289.      This example used an ECHO; however, a GOTO works best on
  290.      ERRORLEVEL.  This prevents you from going to the next IF
  291.      ERRORLEVEL (which is 0 and will also be true).  The syntax
  292.      for the GOTO is:
  293.  
  294.      IF ERRORLEVEL 2 GOTO label2
  295.      IF ERRORLEVEL 1 GOTO label1
  296.  
  297.      :label2
  298.      ECHO = CHOICE RETURNED AN ERRORLEVEL OF 2
  299.  
  300.      :label1
  301.      ECHO = CHOICE RETURNED AN ERRORLEVEL OF 1
  302.  
  303.  
  304.      EXAMPLE 7 - DIREXIST IN THE IF COMMAND
  305.  
  306.      This command when used with IF will check to see if a
  307.      directory exists:
  308.  
  309.           IF DIREXIST F:\ GOTO [:label]
  310.  
  311.      The DIREXIST command can be used to test for the existence
  312.      of drives such as DISK's as well as any subdirectory on a
  313.      disk.  All disk drive have a root directory, so testing for
  314.      F:\ (as in this example) will test for the existence of the
  315.      drive as well as the directory.  Network drives can be
  316.      tested.
  317.  
  318.  
  319.      OTHER EXAMPLES
  320.  
  321.      1.   Selecting different configuration options from the
  322.           CONFIG.SYS file using the ? command.
  323.  
  324.           ?SHELL=C:\COMMAND.COM C:\ /P /E:512
  325.           ?SHELL=C:\COMMAND.COM C:\ /P /E:1024
  326.           ?BREAK=OFF
  327.           ?BREAK=ON
  328.           BUFFERS=20
  329.           FILES=20
  330.           ?HISTORY=ON, 256, ON, OFF, OFF
  331.           ?DEVICE=C:\NWDOS\ANSI.SYS
  332.      
  333.      2.   Selecting different AUTOEXEC.BAT's from CONFIG.SYS
  334.           using the ? and the SHELL statement.  In the SHELL
  335.           statement the /P switch can be followed by a file name.
  336.           When present, the named file will be executed instead
  337.           of the AUTOEXEC.BAT file.  The named file must have a
  338.           .BAT extension and cannot exceed 11 characters
  339.           including path.
  340.  
  341.           ?"Default Autoexec? (y/n) "SHELL=C:\COMMAND.COM C:\ /P
  342.           /E:256 ?"Alternate Autoexec? (y/n)
  343.           "SHELL=C:\COMMAND.COM C:\ /P:ALTERNAT.BAT /E:256
  344.  
  345.      3.   Selecting and using different configuration files from
  346.           CONFIG.SYS at bootup.
  347.  
  348.           ?"Do you want to run Windows? (y/n) " chain =
  349.           WCONFIG.SYS
  350.           ?"Do you want to use QEMM? (y/n) " chain = QCONFIG.SYS
  351.           ?"Do you want to use MemoryMAX? (y/n) " chain =
  352.           MCONFIG.SYS
  353.           ?"Do you want to use 386MAX? (y/n) " chain =
  354.           386CONF.SYS
  355.  
  356.           Each line is printed on the screen and you are asked to
  357.           load and run the chained configuration file.  Each
  358.           configuration file is a complete CONFIG.SYS type file
  359.           with all the appropriate options.
  360.  
  361.      4.   The above configuration using "menu" choices with
  362.           SWITCH.  Note how the "SET environment" variables can
  363.           be used and tested for different AUTOEXEC type files in
  364.           this example.
  365.  
  366.           CONFIG.SYS
  367.  
  368.           ECHO =    1  For Windows Configuration
  369.           ECHO =    2  For QEMM Configuration
  370.           ECHO =    3  For NOVELL DOS 7 MemoryMAX Configuration
  371.           ECHO =    4  For 386MAX Configuration
  372.  
  373.           ECHO =    5  For no Configuration... just exit
  374.           SWITCH win, qemm, memm, 386m, none
  375.           :none
  376.  
  377.           set autoexec=norm
  378.           exit
  379.  
  380.           :win
  381.           set autoexec=win
  382.           chain=wconfig.sys
  383.  
  384.           :qemm
  385.           set autoexec=qemm
  386.           chain=qconfig.sys
  387.  
  388.           :memm
  389.           set autoexec=memm
  390.           chain=mconfig.sys
  391.  
  392.           :386m
  393.           set autoexec=386m
  394.           chain=386conf.sys
  395.  
  396.  
  397.           AUTOEXEC.BAT
  398.  
  399.           @echo off
  400.           PATH C:\NWDOS;C:\;C:\UTIL;
  401.           VERIFY OFF
  402.           PROMPT $P$G
  403.           DISKMAP C: D:
  404.           IF "%autoexec%"=="norm" goto NWDOSEXIT
  405.           SHARE /L:40
  406.           IF "%autoexec%"=="win" SUPERPCK /EM /L:2048
  407.           IF "%autoexec%"=="qemm" CALL QEMM.BAT
  408.           IF "%autoexec%"=="memm" SUPERPCK  /A /L:2048
  409.           IF "%autoexec%"=="386m" CALL 386.BAT
  410.           :NWDOSEXIT
  411.  
  412.      5.   Using ANSI
  413.  
  414.           ANSI escape sequences can be used in batch file
  415.           processing to create colorful menus.  Below is an
  416.           example of a menu that uses the SWITCH command and ANSI
  417.           escape sequences to create a menu.  ANSI.SYS must be
  418.           loaded in the CONFIG.SYS file to allow for cursor
  419.           positioning and colors.
  420.  
  421.           The first character after the Echo statement is an
  422.           ASCII 27 or escape character.  This character may be
  423.           displayed differently on some printers and monitors (in
  424.           fact if you have ANSI loaded you will never see the
  425.           character when typed to the screen).
  426.  
  427.           To type this character using the NOVELL DOS 7 EDIT,
  428.           press the <Ctrl>+<P> then the ESC key.  An alternate
  429.           method is to press <CTRL>+Q then the N key and then
  430.           type the number 27.  Within EDIT, the ESC character
  431.           will appear as:  ^[.
  432.  
  433.  
  434.           If you have downloaded this document from CompuServe or
  435.           the Novell Desktop System Group BBS, the escape
  436.           sequences have been left intact and you can use the
  437.           NOVELL DOS 7 EDIT to block out the Echo statements to a
  438.           file.  Then, if ANSI is loaded when the file is typed
  439.           to the screen, you should see white letters on a
  440.           magenta background.
  441.  
  442.           For additional information on ANSI.SYS and escape
  443.           sequences, refer to Chapter 9 of DOSBOOK, the NOVELL
  444.           DOS 7 online User Guide.
  445.  
  446.           @ECHO OFF
  447.           ECHO  
  448.           ---------------------------------
  449.           ECHO         1. CONTINUE W/O SCAN        
  450.           
  451.           ECHO         2. SCAN FOR VIRUSES         
  452.           
  453.           ECHO                                     
  454.           
  455.           ECHO  
  456.           -----------------------------------
  457.           SWITCH MENUBEGIN,SCAN
  458.  
  459.  
  460.      SAMPLE.BAT
  461.  
  462.      If you have gotten this file from CompuServe or the NOVELL
  463.      Desktop Systems Group BBS, you can run this sample batch
  464.      file.
  465.  
  466.      Starting on the next line, mark a block to the end of file
  467.      (excluding any word processor control characters) and write
  468.      the block to a new file called SAMPLE.BAT.  From the command
  469.      prompt SAMPLE will run the file.
  470.  
  471.      CLS
  472.      @ECHO OFF
  473.  
  474.      REM EXAMPLE1 ******************************************
  475.      ECHO This batch file demonstrates some of the unique 
  476.      ECHO features of Novell DOS batch commands.
  477.      ECHO.
  478.      ECHO.
  479.      ECHO The first example tests to make sure you are using
  480.      ECHO Novell DOS.  It uses an IF statement.  The IF
  481.      ECHO tests for an environment variable called OS.
  482.      ECHO Press a key to begin.
  483.      PAUSE>NUL
  484.      ECHO.
  485.      ECHO The Operating System variable indicates "%OS%".
  486.  
  487.      IF NOT "%OS%"=="NWDOS" GOTO WRONGDOS
  488.  
  489.      ECHO This means that the current operating system
  490.      ECHO is Novell DOS.
  491.      ECHO.
  492.      ECHO Below is the line that was used in the batch file:
  493.      ECHO.
  494.      ECHO IF NOT "%%OS%%"=="NWDOS" GOTO WRONGDOS
  495.  
  496.      ECHO.
  497.      ECHO The environment table contains the line: OS=%OS%.
  498.      ECHO This was inserted automatically by Novell DOS.
  499.      ECHO The batch processor replaces "%%OS%%" with "%OS%"
  500.      ECHO from the environment table.  Since "%OS%" is
  501.      ECHO equal to "NWDOS", the statement is false and the
  502.      ECHO GOTO is not executed.
  503.      ECHO.
  504.      ECHO IF statements are only executed if TRUE.  The
  505.      ECHO logic of the above statement can be confusing
  506.      ECHO because at first glance it looks true.  However,
  507.      ECHO the NOT portion reverses the statement to
  508.      ECHO something like "IF "%OS%" IS NOT EQUAL TO
  509.      ECHO "NWDOS" THEN GOTO WRONGDOS."  Press any key when
  510.      ECHO you are ready to continue.
  511.      PAUSE>NUL
  512.      CLS
  513.  
  514.      REM EXAMPLE2 ******************************************
  515.      ECHO.
  516.      ECHO This next example is the CHOICE command.
  517.      ECHO.
  518.  
  519.      CHOICE /C:XY Select X or Y for a message ...
  520.      CLS
  521.      IF ERRORLEVEL 2 ECHO MESSAGE: CHOICE RETURNED AN ERRORLEVEL
  522.      OF 2
  523.      IF ERRORLEVEL 1 ECHO MESSAGE: CHOICE RETURNED AN ERRORLEVEL
  524.      OF 1
  525.  
  526.      ECHO.
  527.      ECHO The CHOICE command is an external program that
  528.      ECHO returns an ERRORLEVEL for certain preselected keys.
  529.      ECHO They can then be tested with IF to make branches
  530.      ECHO in a batch file.  Up to 99 different errors can be 
  531.      ECHO returned.  Three lines were used to create this
  532.      ECHO example:
  533.      ECHO.
  534.      ECHO CHOICE /C:XY Select X or Y for a message ...
  535.      ECHO IF ERRORLEVEL 2 ECHO MESSAGE: CHOICE RETURNED
  536.      ECHO AN ERRORLEVEL 2 IF ERRORLEVEL 1 ECHO
  537.      ECHO MESSAGE: CHOICE RETURNED AN ERRORLEVEL 1
  538.      ECHO.
  539.      ECHO The switch /C:XY tells choice to use the
  540.      ECHO keys X and Y. They  are not case sensitive.
  541.      ECHO The letter X will be errorlevel 1 and
  542.      ECHO Y will be errorlevel 2.  The remaining text
  543.      ECHO is the displayed message.
  544.      ECHO.
  545.  
  546.      IF ERRORLEVEL 2 ECHO Because you chose the letter Y you
  547.      actually received two messages.
  548.      IF ERRORLEVEL 2 ECHO This points out one of the tricks to
  549.      using ERRORLEVEL. When the
  550.      IF ERRORLEVEL 2 ECHO ERRORLEVEL is tested a logic is used
  551.      that considers the statement to be
  552.      IF ERRORLEVEL 2 ECHO true if the value is equal to or
  553.      greater than the returned error.  In the
  554.      IF ERRORLEVEL 2 ECHO example used here: ERRORLEVEL=2 (letter
  555.      Y),
  556.      IF ERRORLEVEL 2 ECHO is true so the message is displayed.
  557.  
  558.      The second statement
  559.      IF ERRORLEVEL 2 ECHO IF ERRORLEVEL 1 is also true (because
  560.      the returned value of 2 is greater
  561.      IF ERRORLEVEL 2 ECHO than or equal to 1) so the message is
  562.      displayed.
  563.      IF ERRORLEVEL 2 GOTO ERROR2
  564.  
  565.      IF ERRORLEVEL 1 ECHO You should always perform the IF tests
  566.      beginning with the highest
  567.      IF ERRORLEVEL 1 ECHO ERRORLEVEL first.  This is because the
  568.      IF evaluates the statement based
  569.      IF ERRORLEVEL 1 ECHO on whether the returned value is equal
  570.      or greater than the IF statement.
  571.      IF ERRORLEVEL 1 ECHO In the example used here:  ERRORLEVEL=1
  572.      (letter X).  The first statement
  573.      IF ERRORLEVEL 1 ECHO IF ERRORLEVEL 2 is FALSE so the message
  574.      is not displayed. The second
  575.      IF ERRORLEVEL 1 ECHO statement IF ERRORLEVEL 1 is true so
  576.      the message is displayed.  This
  577.      IF ERRORLEVEL 1 ECHO example used an ECHO but a GOTO works
  578.      best on ERRORLEVEL.  This prevents
  579.      IF ERRORLEVEL 1 ECHO you from going to the next IF
  580.      ERRORLEVEL (which is 0 and will also be
  581.      IF ERRORLEVEL 1 ECHO true).  EDIT this batch file to see how
  582.      the tests are performed.
  583.  
  584.      :ERROR2
  585.      pause
  586.      CLS
  587.  
  588.      REM EXAMPLE3 ******************************************
  589.  
  590.      ECHO.
  591.      ECHO Next is a check to see if a directory exists. Novell
  592.      ECHO DOS has a command called DIREXIST. This command
  593.      ECHO when used with IF will check to see if the
  594.      ECHO directory F:\ exists.  Press any key to begin.
  595.      PAUSE>NUL
  596.  
  597.      IF DIREXIST F:\ GOTO EXIST
  598.      CLS
  599.      ECHO.
  600.      ECHO The directory does not exist!
  601.      ECHO The command was:
  602.      ECHO.
  603.      ECHO IF DIREXIST F:\ GOTO EXIST
  604.      ECHO.
  605.      ECHO The directory did not exist, so the GOTO was
  606.      ECHO not executed.
  607.      ECHO.
  608.      ECHO The DIREXIST command can be used to test for the
  609.      ECHO existence of drives such as VDISK's as well as any
  610.      ECHO subdirectory on a disk. All disk drive have a root
  611.      ECHO directory so testing for F:\ (as in this example)
  612.      ECHO will test for the existence of the drive as well
  613.      ECHO as the directory.  Network drives can be tested.
  614.      GOTO EXAMPLE4
  615.  
  616.      :EXIST
  617.      CLS
  618.      ECHO.
  619.  
  620.      ECHO The directory exists!
  621.      ECHO The command was:
  622.      ECHO.
  623.      ECHO IF DIREXIST F:\ GOTO EXIST
  624.      ECHO.
  625.      ECHO The directory does exist, so the GOTO was
  626.      ECHO performed.
  627.      ECHO.
  628.      ECHO The DIREXIST command can be used to test for the
  629.      ECHO existence of drives such as VDISK's as well as any
  630.      ECHO subdirectory on a disk.  All disk drives have a
  631.      ECHO root directory so testing for F:\ (as in this
  632.      ECHO example) will test for the existence of the drive
  633.      ECHO as well as the directory.  Network drives can
  634.      ECHO be tested and in fact F:\ may be one of your
  635.      ECHO network drives.
  636.      ECHO.
  637.  
  638.  
  639.      REM EXAMPLE4 ******************************************
  640.  
  641.      :EXAMPLE4
  642.      ECHO Press any key to continue
  643.      PAUSE>NUL
  644.      CLS
  645.      ECHO The SWITCH command can be used in both Batch 
  646.      ECHO files and Config files. It waits for a number
  647.      ECHO to be entered and then performs a GOSUB.  The
  648.      ECHO TIMEOUT command used in the CONFIG.SYS file
  649.      ECHO will result in the first option being chosen.
  650.      ECHO Also, the ENTER key will also be accepted as
  651.      ECHO the first option.
  652.      ECHO.
  653.      ECHO   Select 1 or 2
  654.      ECHO.
  655.      ECHO Option 1 has a RETURN. Option 2 does not have
  656.      ECHO a RETURN and functions like a GOTO.
  657.      ECHO.
  658.  
  659.      SWITCH LABEL1,LABEL2
  660.      ECHO.
  661.      ECHO This is the RETURN.
  662.      GOTO PRELUDE1
  663.  
  664.      :LABEL1
  665.      CLS
  666.      ECHO This is the first switch!
  667.      RETURN
  668.  
  669.      :LABEL2
  670.      CLS
  671.      ECHO This is the second switch!
  672.      ECHO.
  673.      ECHO The SWITCH lines looked like this:
  674.      ECHO          SWITCH LABEL1,LABEL2
  675.      ECHO          ECHO.
  676.      ECHO          ECHO This is the RETURN.
  677.      ECHO          GOTO PRELUDE1
  678.      ECHO.
  679.      ECHO          :LABEL1
  680.      ECHO          ECHO This is the first switch!
  681.  
  682.      ECHO          RETURN
  683.      ECHO.
  684.      ECHO          :LABEL2
  685.      ECHO          ECHO This is the second switch!
  686.      ECHO          etc...
  687.      ECHO.
  688.      ECHO          :PRELUDE1
  689.      ECHO.
  690.      ECHO You selected the key 2 so SWITCH did a GOSUB
  691.      ECHO to the label :LABEL2.  There was no RETURN in
  692.      ECHO LABEL2 so it continued to the LABEL, PRELUDE1.
  693.      ECHO Press any key to continue.
  694.      PAUSE>NUL
  695.      GOTO EXAMPLE5
  696.  
  697.      :PRELUDE1
  698.      ECHO.
  699.      ECHO The SWITCH lines looked like this:
  700.      ECHO          SWITCH LABEL1,LABEL2
  701.      ECHO          ECHO.
  702.      ECHO          ECHO This is the RETURN.
  703.      ECHO          GOTO PRELUDE1
  704.      ECHO.
  705.      ECHO          :LABEL1
  706.      ECHO          ECHO This is the first switch!
  707.      ECHO          RETURN
  708.      ECHO.
  709.      ECHO          :LABEL2
  710.      ECHO          ECHO This is the second switch!
  711.      ECHO          etc...
  712.      ECHO.
  713.      ECHO          :PRELUDE1
  714.      ECHO.
  715.      ECHO You selected the key 1 so SWITCH did a GOSUB to
  716.      ECHO the label :LABEL1. The RETURN brought it back
  717.      ECHO to the line immediately after the SWITCH.
  718.      ECHO Press any key to continue.
  719.      PAUSE>NUL
  720.  
  721.  
  722.      REM EXAMPLE5 ******************************************
  723.  
  724.      :EXAMPLE5
  725.      CLS
  726.      ECHO This example displays some of the System
  727.      ECHO Information Variables (SIV's).  The SIV's are
  728.      ECHO special variables that can be used in batch
  729.      ECHO files to help control execution or just to make
  730.      ECHO the OS "friendlier".  Press any key to continue.
  731.      PAUSE>NUL
  732.      ECHO.
  733.      ECHO Good %Greeting_Time%.  The current computer time
  734.      ECHO is %Hour24%:%Minute%:%Second%.
  735.      ECHO.
  736.      ECHO Today's date is %Month_Name% %Day%, %Year%.
  737.      ECHO.
  738.      IF NOT "%Login_Name%"=="" ECHO You are logged into the
  739.      Network as %Login_Name%.
  740.      ECHO.
  741.      IF NOT "%Station%"=="" ECHO You are attached to station
  742.      %Station%.
  743.  
  744.      ECHO.
  745.      GOTO END
  746.  
  747.      :WRONGDOS
  748.      ECHO.
  749.      ECHO If you were running Novell DOS the OS variable
  750.      ECHO would return "NWDOS."  Since all of the tests
  751.      ECHO performed by this batch file need Novell DOS
  752.      ECHO to work correctly this batch program will now 
  753.      ECHO stop.  Please try again when Novell DOS is running.
  754.      ECHO.
  755.  
  756.  
  757.      :END
  758.      ECHO Thanks for running this Sample batch file.
  759.      ECHO Please feel free to explore the contents of the
  760.      ECHO file.  The examples displayed in this file are
  761.      ECHO fairly straightforward.  Much more sophisticated
  762.      ECHO batch files can be easily made. Experiment!
  763.