home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 8 / CDASC08.ISO / VRAC / PCL60A.ZIP / PART2.EXE / DOSTIPS.TUT < prev    next >
Text File  |  1993-07-13  |  38KB  |  840 lines

  1.        
  2.        The following information is reprinted with permission, Ultimate 
  3.        Power Tips 1.0A (c) 1992, 1993  Paul Scanlon, Scanlon Enterprises 
  4.        
  5.        ------------------------------------------------------------
  6.  
  7.                                  DOS POWER TIPS
  8.  
  9.        ------------------------------------------------------------
  10.  
  11.  
  12.         Getting More Memory From DOS
  13.  
  14.         Would you like more memory for your application(s)? Beginning 
  15.         with DOS 5.0, Microsoft is allowing users with extended memory 
  16.         (286 systems and up), to place much of the DOS operating system 
  17.         into high memory. By adding a couple of lines to your CONFIG.SYS 
  18.         file, you can have a conventional memory size report from MEM 
  19.         like this :
  20.  
  21.             655360 bytes total conventional memory
  22.             655360 bytes available to MS-DOS
  23.             617520 largest executable program size
  24.  
  25.         On a 386 machine, you get even more. Just start your CONFIG.SYS 
  26.         file with these lines :
  27.  
  28.         DOS=HIGH
  29.         device=C:\UTILS\TSR1\himem.sys
  30.  
  31.         Now your application can have over 617K of ram!
  32.  
  33.  
  34.  
  35.  
  36.         Smoother DOS
  37.  
  38.         I have noticed on many client machines, the trend to clump many 
  39.         files into the ROOT directory of the boot drive (usually C:). 
  40.         Not only does this slow DOS down, but it could be the potential 
  41.         for some real problems. On floppies, there is a limit of 112 
  42.         files for a root directory. This means, that when there are 112 
  43.         files, DOS will give an error report, of "unable to create file" 
  44.         on the next attempt to create a file, even temporary files, 
  45.         which many word processors need. In fact, there are many 
  46.         applications which create temporary files in the root directory. 
  47.         If you keep adding files to the root (other than these temporary 
  48.         ones), then eventually, the application itself will fail! I 
  49.         suggest, as an experienced consultant, that you create and 
  50.         maintain several directories, including layered ones.
  51.  
  52.         For instance, ALL DOS programs, should go into a directory 
  53.         called DOS, just off the root. The only files DOS needs in the 
  54.         root at boot time, are COMMAND.COM and CONFIG.SYS ! Everything 
  55.         else, including your mouse drive and ANSI.SYS should be in a 
  56.         directory. Another directory you should create, is one called 
  57.         BAT (or BATCH), where you should place all those short batch 
  58.         files (they don't belong in the root directory). There is only 
  59.  
  60.         one batch file which should be in the root, and that is 
  61.         AUTOEXEC.BAT!
  62.  
  63.         What of layered directories ? If like me, you collect utilities, 
  64.         then you should keep those most often used in one directory and 
  65.         the rest in another, and NOT in the root directory! A layered 
  66.         directory is one which is inside another. For instance, on my 
  67.         machine, I created a directory called UTILS, which itself, 
  68.         contains only other directory names. Inside UTILS, I created 
  69.         directories with names of L1, L2, L3, etc... and each one has 
  70.         utilities, which are of lesser and lesser importance, with L1 
  71.         containing the most often used.
  72.  
  73.         Why this struggle to remove files from the root and use of 
  74.         layered directories? Because, DOS must search for whatever you 
  75.         type at a DOS prompt, or what is requested from a batch file. 
  76.         DOS will search a 10 entry directory faster than a 100 entry 
  77.         directory! You WILL notice this extra speed! The layered 
  78.         directories adds to this approach. When you made your AUTOEXEC 
  79.         batch file, you added a line starting with "PATH=", which 
  80.         contains the search string for DOS. This search string tells DOS 
  81.         where to begin looking for executable programs, after checking 
  82.         the current directory. For this reason, I place my DOS directory 
  83.         as the first search entry like this : PATH=C:\DOS
  84.  
  85.         If all of your executables were in this one directory, that 
  86.         would be all you needed! This would be the case for small hard 
  87.         drives, such as the old 10MB and 20MB drives. This is NOT the 
  88.         case for systems with dozens of applications, which can be 
  89.         executed from any DOS prompt. In my case, for example, I created 
  90.         the extra utility directories inside a main directory called 
  91.         UTILS, with the names of L1, L2, L3, etc.. In this case, my PATH 
  92.         statement, in my AUTOEXEC has the following PATH statement:
  93.  
  94.                 PATH=C:\DOS;C:\UTILS\L1;C:\UTILS\L2;C:\UTILS\L3
  95.  
  96.         We prefix the path, with a drive letter, because, we might be on 
  97.         drive A or B when we request a utility or DOS function. Notice 
  98.         the semicolon between entries. DOS requires these to delimit one 
  99.         path entry from another. A well designed hard drive, will have 
  100.         less than 20 entries in the root directory!
  101.  
  102.  
  103.  
  104.         Easy Disk Transfer
  105.  
  106.         Add the following two batch files to your system to make copying 
  107.         files from drive A to your hard drive easy. The batch file 
  108.         TOA.BAT copies selected (or all) files to drive A, while the 
  109.         batch file FROMA.BAT copies selected (or all) files from drive 
  110.         A. By using these two batch files, you can avoid have to retype 
  111.         and retype the DOS COPY command.
  112.  
  113.                 TOA.BAT
  114.  
  115.                 REM ------------------
  116.                 REM -   TOA.BAT      -
  117.                 REM ------------------
  118.                 REM Copy several files to drive A:
  119.                 ECHO OFF
  120.                 IF NOT %1* == * GOTO LPB
  121.                 COPY *.* A:
  122.                 :LPA
  123.                 SHIFT
  124.                 :LPB
  125.                 IF %1* == * GOTO XIT
  126.  
  127.                 COPY %1 A:
  128.                 GOTO LPA
  129.                 :XIT
  130.                 REM End of batch file
  131.  
  132.                 FROMA.BAT
  133.  
  134.                 REM -------------------
  135.                 REM -   FROMA.BAT     -
  136.                 REM -------------------
  137.                 REM Copy several files from drive A:
  138.                 ECHO OFF
  139.                 IF NOT %1* == * GOTO LPB
  140.                 COPY A:*.*
  141.                 :LPA
  142.                 SHIFT
  143.                 :LPB
  144.                 IF %1* == * GOTO XIT
  145.                 COPY A:%1
  146.                 GOTO LPA
  147.                 :XIT
  148.                 REM End of batch file
  149.  
  150.         Now, if you want to copy, for example, 3 files to drive A:, 
  151.         called MYF1, MYF2 & MYF3 you simply enter :
  152.  
  153.                 TOA MYF1 MYF2 MYF3
  154.  
  155.         If the same files were on A: and you wanted them on C: you'd 
  156.         enter this :
  157.  
  158.                 FROMA MYF1 MYF2 MYF3
  159.  
  160.         These batch files examples can easily be modified to include 
  161.         other drives, such as B: or D: !
  162.  
  163.  
  164.  
  165.         Batch File, Know Thy Self
  166.  
  167.         Do you have a batch file which must be run on drive A: only, 
  168.         such as an INSTALL.BAT file? Add these few lines to your batch 
  169.         file, and it will know if it is running on drive A: (Assume the 
  170.         batch file name is INSTALL.BAT).
  171.  
  172.                 IF NOT %0 == A:INSTALL.BAT GOTO DRVERR
  173.                 {Your batch file commands}
  174.                 GOTO XIT
  175.                 :DRVERR
  176.                 ECHO You must start this batch file from drive A:
  177.                 :XIT
  178.  
  179.         DOS sets batch file %0 equal to the path (including drive) and 
  180.         file name of the current running batch file.
  181.  
  182.  
  183.  
  184.         The Invisible DOS TYPE Command
  185.  
  186.         DOS has several built in commands, one of which is the COPY 
  187.         command. This is normally used, to transfer files from one disk 
  188.         to another. This remarkable utility can also, display or print a 
  189.         file. To print a file, simply use the following:
  190.  
  191.                 COPY filename PRN
  192.  
  193.  
  194.         Where "filename" is any valid DOS file name, which may include 
  195.         drive and path. Alternately, you may substitute LPTn for PRN, 
  196.         where "n" is in the range of 1 - 4 on PC compatible machines and 
  197.         1 - 9 on PS/2 compatible machines. To display a file, simply 
  198.         enter the following :
  199.  
  200.                 COPY filename CON
  201.  
  202.         Where "filename" is the same as above. You will have to be quick 
  203.         to stop the scrolling, as it will scroll off screen, if you do 
  204.         NOT use the PAUSE key to halt it. The advantage of using this 
  205.         approach for printing, is that the DOS redirector ">" does NOT 
  206.         have to be used, as when using the TYPE command, IE.. TYPE 
  207.         filename > PRN . Another advantage of using COPY, is that if you 
  208.         are on a strange machine, and it doesn't have TYPE.COM anywhere 
  209.         around, then you can use COPY as it's a built in DOS function, 
  210.         and does NOT require an external program to execute.
  211.  
  212.  
  213.  
  214.         Use Your Computer as a Typewriter
  215.  
  216.         To type directly from the keyboard to a printer, a quick yet 
  217.         easy way is to use "COPY CON PRN". This is entered directly from 
  218.         a DOS prompt. You won't have word wrap, or other wordprocessor 
  219.         features, but you can correct any text entered on the current 
  220.         line. You simply enter a line of text, and press {Enter} after 
  221.         assuring that the line is correct. Once entered the last line to 
  222.         send to the printer, hold the Control key down and press the "Z" 
  223.         key. Release both keys and press {Enter}. Everything that you 
  224.         have typed will be printed on your printer.
  225.  
  226.  
  227.  
  228.         Protecting System Files From Accidental Deletion
  229.  
  230.         You're working in an application directory on your hard disk 
  231.         with a job running longer than expected. So you decide to make 
  232.         room on a recycled floppy to copy files and finish the project 
  233.         at home. You type "DIR A:" and see that you no longer need the 
  234.         data on the floppy disk, but then you type "DEL *.*", and when 
  235.         DOS asks "Are You Sure (Y/N) ?", you answer "Y", erasing all the 
  236.         files in your application directory! Protect yourself from this 
  237.         type of accidental erasure, by using the DOS command "ATTRIB +R 
  238.         *.*" to make all files in your applications directory read-only. 
  239.         You can un-protect individual files that require regular 
  240.         updating (personal dictionaries and so on) by typing "ATTRIB -R 
  241.         filename".
  242.  
  243.  
  244.  
  245.         Easy On-Line Reminders
  246.  
  247.         If you can't always remember short but complex procedures and 
  248.         command sequences (printer setup codes and the like), jog your 
  249.         memory with brief, on-line ASCII how-to files created with your 
  250.         text editor or word processor. Format the files so that they're 
  251.         easily readable in a single screen. Give them names you'll have 
  252.         no trouble remembering, and store them in a directory call 
  253.         "\HELP". Then add a batch file called "HELP.BAT", which contains 
  254.         the line "TYPE \HELP\%1", to your batch file directory, which is 
  255.         contained in the PATH statement, of your AUTOEXEC.BAT file. When 
  256.         you need assistance, use the DOS command "HELP filename" to get 
  257.         an instant refresher course.
  258.  
  259.  
  260.  
  261.  
  262.         Determining Your Rom Bios Date
  263.  
  264.         If you are experiencing problems with a hardware upgrade, you 
  265.         can use the DEBUG utility (which came on one of your DOS disks) 
  266.         to check the date of your computer's Rom Bios. Run DEBUG, and at 
  267.         the hyphen "-" prompt type DFFFF:5 L8 and press {Enter}. Your 
  268.         system's Rom Bios Date will appear on the right side of your 
  269.         screen. Press Q then {Enter} to return to a DOS prompt.
  270.  
  271.  
  272.  
  273.         A Quicker Exit
  274.  
  275.         If you frequently shell out of applications or an environment, 
  276.         you probably  get plenty of practice typing "EXIT" and pressing 
  277.         {Enter} to return to the application. You can save yourself some 
  278.         keystrokes by creating a batch file called E.BAT that contains 
  279.         the line "EXIT". This batch file should be in a directory listed 
  280.         in the PATH of your system.
  281.  
  282.  
  283.  
  284.         The Shell in the Shell
  285.  
  286.         If the WordPerfect Library shell loads inside of itself, you DOS 
  287.         prompt will read something like "(SHELL)(SHELL)C::>", and {F7} 
  288.         won't bring back the Library screen. To solve the problem, type 
  289.         EXIT and press {Enter}, then press {F7} at the Library screen, 
  290.         repeating the process until your prompt has only one "(SHELL)". 
  291.         To avoid the problem, regularly use {F7} rather than the SHELL 
  292.         command to return to the Library.
  293.  
  294.  
  295.  
  296.         Where's That Ram
  297.  
  298.         More and more VGA Boards are sporting 512K or more of Ram. But 
  299.         if you check video RAM with the current version of most programs 
  300.         like Chekit, System Sleuth or Norton Utils, they show up to 256K 
  301.         only. Not to worry, the additional Ram is really there, but the 
  302.         BIOS calls (standard) do not yet support for video ram sizes 
  303.         greater than 256K.
  304.  
  305.  
  306.  
  307.         DOS FILES and BUFFERS CONFIG.SYS commands
  308.  
  309.         The CONFIG.SYS file, MUST be located in the ROOT directory of 
  310.  
  311.         the boot drive. This file, contains commands to set some DOS 
  312.         resources plus installation of Device Drivers, such as that for 
  313.         the Mouse. By default, DOS reserves small portions of memory to 
  314.         use, to track and manage a number of disk drives, open files, 
  315.         standard devices such as the video and keyboard, and disk data 
  316.         buffers. The FILES command lets you increase the maximum number 
  317.         of simultaneously open files, a necessity of modern applications 
  318.         that open multiple data, index or internal utility (such as a 
  319.         spelling checker) files. In DOS versions prior to 3.3, FILES 
  320.         could NOT be set greater than 20! With newer DOS versions, we 
  321.         can now set FILES to as high as 255! BUFFERS, is a command to 
  322.         enable a selected number of disk buffers, DOS's built in disk 
  323.         cache system. The larger the number of Buffers, the more disk 
  324.         cache available to DOS, and the less memory available to your 
  325.         application program. The ideal setting for FILES, depends on the 
  326.         applications you are running. Many applications, upon 
  327.         installation, modify the CONFIG.SYS file to make FILES the 
  328.         correct size for that application. Other applications, simply 
  329.         warn the user to have FILES set to the correct value. Find the 
  330.         application requesting the largest number of FILES and set FILES 
  331.         to that number, plus 2, for each TSR you may have, which access 
  332.         files. IE.. your word processor wants 20, and you have 3 TSR 
  333.         programs running that access files, then set FILES=26 in your 
  334.         CONFIG.SYS file. If you are running DOS versions prior to 3.3, 
  335.         there are some Shareware utilities which can set the max FILES 
  336.         to larger than the DOS limit of 20!  The BUFFERS command sets up 
  337.         the DOS internal buffers, which hold copies of recent disk I/O. 
  338.         Whenever an application wants to read or write data to a disk, 
  339.         DOS first checks the disk buffers to see if the requested data 
  340.         is there. If the data is, then disk I/O is NOT necessary. This 
  341.         speeds up your application.  Of course, having too many BUFFERS 
  342.         can slow things down, as this would mean more searching. The 
  343.         optimum number of BUFFERS depends in part upon the 
  344.         characteristics and types of drives on you system, the 
  345.         application types and  number of directories and sub-
  346.         directories. For example, having a large number of buffers does 
  347.         NOT improve performance of applications that access files 
  348.         sequentially, but can dramatically reduce the execution time of 
  349.         programs that access files randomly, especially files with small 
  350.         record sizes, such as an index file. Increasing BUFFERS is also 
  351.         useful for systems with layered directories (several layers). If 
  352.         you are, however, using a disk cache system, then you should set 
  353.         BUFFERS=1 (see your cache system manual).
  354.  
  355.  
  356.  
  357.         ATTRIB to the Rescue!
  358.  
  359.         You can find files with the DOS ATTRIB command just as easily as 
  360.         using the program WHEREIS! Simply enter "ATTRIB *.TXT /S" will 
  361.         find all TXT extension files, listing them to the display. Want 
  362.         a listing ? Then use "ATTRIB *.TXT /S>TXT.LST" will put the 
  363.         listing into the file "TXT.LST".
  364.  
  365.         Another useful use of ATTRIB, is to force programs which will 
  366.         not accept will cards, to perform their task over a range of 
  367.         several files, without having to enter each one manually. We can 
  368.         do this across directories. First, we must set the archive bit 
  369.         on all files we want to perform a task on. Do this with the 
  370.         command "ATTRIB +A *.TXT /S". Next, rename the program that you 
  371.         want to operate on all the selected files, in our example, we 
  372.         will use POWER.COM, to A.extension (our example is A.COM). Now, 
  373.         use attrib to make a batch file, like so, "ATTRIB *.TXT 
  374.         /S>OPT.BAT". The batch file thus created, will contain a list of 
  375.         each TXT extension file, preceded by A, such as "A 
  376.         C:\MYTXT.TXT". Now executing the batch file will cause our 
  377.  
  378.         program POWER.COM, renamed to A.COM, to operate on all TXT 
  379.         extension files!
  380.  
  381.  
  382.  
  383.         A Different DOS Backup System, for FREE
  384.  
  385.         You can use the DOS ATTRIB and XCOPY to make a very powerful 
  386.         back up system. The DOS BACKUP command, is know as having many 
  387.         bugs and restore problems, especially if restoring between DOS 
  388.         versions. To back up your system for the first time, use the 
  389.         following ATTRIB command line.
  390.  
  391.                 ATTRIB +A *.* /S
  392.  
  393.         This will SET all file archive flags, in all directories of the 
  394.         current drive. We can now begin the backing up all files. First, 
  395.         have a stack of formatted disks ready for you backup. For 40 
  396.         megabytes of data, you will need; 110 360K disks, 33 1.2Meg 
  397.         disks, 55 720K disks or 28 1.44meg disks. Now, at your DOS 
  398.         prompt, enter the following command line.
  399.  
  400.                 XCOPY *.* A: /A /S /E
  401.  
  402.         This will fill the first disk and exit with a "Disk Full" 
  403.         message. Simply ignore the error, and replace the full disk, 
  404.         with an empty one, press the [F3] key to duplicate the previous 
  405.         command (or retype it), and repeat this process, until there are 
  406.         no files to copy. After making this initial set, you will only 
  407.         need to back up new or modified files. Doing this, simply 
  408.         requires you to have enough formatted disk ready to copy the new 
  409.         data (usually one disk is enough). Now type the line beginning 
  410.         with "XCOPY" from above, and all NEW files will be cloned on 
  411.         your disk. Using this process, also makes the directories on the 
  412.         floppy as it goes, including empty ones. The only draw back to 
  413.         this method, is attempting to back up files larger than the 
  414.         selected disk size. IE... a 360K disk will only hold a file up 
  415.         to 360K in size.
  416.  
  417.  
  418.  
  419.         Stop Struggling With The DOS Format Command
  420.  
  421.         Do you often format different density disks in the same drive? 
  422.         Here is a quick batch file, which will save you keystrokes.
  423.  
  424.         @ECHO OFF
  425.         REM FORMAT.BAT
  426.         REM RENAME THE DOS FORMAT.COM TO FORMAT!.COM
  427.         GOTO %1
  428.         :HELP
  429.         ECHO You must specify the type of disk you want to format
  430.         ECHO FORMAT 360 will format a 360K disk in drive A:
  431.         ECHO FORMAT 12 will format a 1.2MB disk in drive A:
  432.         ECHO FORMAT 720 will format a 720K disk in drive B:
  433.         ECHO FORMAT 144 will format a 1.44MB disk in drive B:
  434.         ECHO Do NOT include the drive letter
  435.         ECHO Other FORMAT options are OK
  436.         GOTO DONE
  437.         :360
  438.         FORMAT! A: /N:09 /T:40 %2 %3 %4
  439.         GOTO DONE
  440.         :12
  441.         FORMAT! A: /N:15 /T:80 %2 %3 %4
  442.         GOTO DONE
  443.         :720
  444.  
  445.         FORMAT! B: /N:09 /T:80 %2 %3 %4
  446.         GOTO DONE
  447.         :144
  448.         FORMAT! B: /N:15 /T:80 %2 %3 %4
  449.         GOTO DONE
  450.         :DONE
  451.  
  452.         If your drives are different that the above, simply edit the 
  453.         lines, to the correct drive letter. Remember, 5¼ inch drives are 
  454.         360K and 1.2MB while 3½ inch drives are 720K and 1.44MB. Thus, 
  455.         if your drive A: is 3½ instead of B:, then simply change the 
  456.         above A:'s to B:'s and B:'s to A:'s !
  457.  
  458.  
  459.  
  460.         FREE File Viewer From DOS
  461.  
  462.         If you want a FREE file viewing utility, you have one already! 
  463.         Many of you already are aware of using the good old line of
  464.  
  465.                 TYPE filename | MORE
  466.  
  467.         Save your self some typing and create the following one line 
  468.         batch file calling it TYP.BAT
  469.  
  470.                 MORE < %1
  471.  
  472.         This results in the same output as the earlier one using the DOS 
  473.         command TYPE! The %1 will be replaced at execution time, by the 
  474.         specified file name, such as TYP MYFILE ! Of course, this 
  475.         feature does NOT support paging or scrolling features found in 
  476.         many good FileListing utilities. However, if you're just 
  477.         interested in viewing a file to see if it's worth keeping or 
  478.         printing this is fast and easy to use. To abort the scrolling, 
  479.         simply press <Ctrl>C or <Ctrl><Break>! To move from to the next 
  480.         video page, press any key!
  481.  
  482.  
  483.  
  484.         A No Text Editor Method of Creating Short Batch Files
  485.  
  486.         Need to create a one line or short batch file? You don't even 
  487.         need to start your text editor or word processor. At a DOS 
  488.         prompt, enter the following single line:
  489.  
  490.         COPY CON filename
  491.  
  492.         Replace "filename", with the name of the file you want to 
  493.         create. Press <ENTER> after "filename". The cursor will be 
  494.         located to the next line, and you begin entering keystrokes just 
  495.         as though you were using a text editor. You will NOT be able to 
  496.         edit a previous line (you can't cursor up). Once you are though, 
  497.         all text lines entered, press <F6> <ENTER>. You will get a DOS 
  498.         prompt back.
  499.  
  500.  
  501.  
  502.         More Ram For Your Applications
  503.  
  504.         Here's a way to save 1K or more of application ram, if you are 
  505.         loading TSR's into ram from your AUTOEXEC batch file. The trick, 
  506.         is to arrange you startup commands efficiently. Put DOS commands 
  507.         that don't increase the size of the environment, such as CHKDSK, 
  508.         ECHO and BREAK at the beginning of AUTOEXEC. Now load your TSR 
  509.         applications, making sure to include the path names. This is 
  510.         done prior to setting the path or other environ variables such 
  511.  
  512.         as COMSPEC. After loading your TSR's you can execute any command 
  513.         which will increase the environ size, such as PATH and PROMPT.
  514.  
  515.         The reason we can gain memory in this manner, is because each 
  516.         time an application is loaded, DOS gives the application a COPY 
  517.         of the ENVIRON area, which includes PATH settings, etc... If we 
  518.         start our TSR's prior to setting any ENVIRON variables, we will 
  519.         give a TSR a smaller ENVIRON area! In this way, if your ENVIRON 
  520.         space uses 200 bytes and you have 5 TSR applications you'll save 
  521.         1K byte!
  522.  
  523.  
  524.  
  525.         FOR POWER!
  526.  
  527.         The DOS batch command FOR, can invoke several commands on a 
  528.         single line, to speed up your batch files. Consider an AUTOEXEC 
  529.         batch file that has the following 3 lines.
  530.  
  531.                 PROMPT=$P$G
  532.                 TSR1
  533.                 TSR2
  534.  
  535.         DOS must access the disk 3 times to read those 3 commands. 
  536.         Instead, pack all 3 commands into 1 line, using FOR :
  537.  
  538.                 FOR %%F IN (PROMPT=$P$G TSR1 TSR2) DO %%F
  539.  
  540.         This single line batch command replaces the previous 3 lines! In 
  541.         this case, the FOR command takes each entry (space delimited) 
  542.         and substitutes them for the variable %%F. In this way, DOS will 
  543.         only need to access the disk 1 time to read the 3 commands, 
  544.         instead of the previous 3 times! The one restriction with this 
  545.         tip is that programs executed in this fashion, can NOT have an 
  546.         argument passed to them. Also, the FOR command interprets 
  547.         semicolons as delimiters, just as it does spaces, so, you can 
  548.         NOT include your PATH command in a FOR command.
  549.  
  550.  
  551.  
  552.         Batch Files That Count
  553.  
  554.         Use this counting routine in batch files to perform routine 
  555.         tasks, such as backups, that you want to execute at regular 
  556.         intervals. The batch file COUNT.BAT, for example, used in your 
  557.         AUTOEXEC.BAT file, will automatically run CHKDSK /F command 
  558.         every third time you reboot. COUNT.BAT creates a zero byte file 
  559.         and uses its name as the counter. Create the batch file, 
  560.         COUNT.BAT, then add the line CALL COUNT.BAT to your AUTOEXEC.BAT 
  561.         file.
  562.  
  563.                 ECHO OFF
  564.                 CLS
  565.                 IF NOT EXIST BOOT? GOTO NO
  566.                 FOR %%F IN (BOOT3 BOOT2 BOOT1) DO IF EXIST %%F GOTO %%F
  567.                 GOTO ERROR
  568.                 :NO
  569.                 TYPE >BOOT2
  570.                 GOTO END
  571.                 :BOOT3
  572.                 REN BOOT3 BOOT1
  573.                 CHKDSK /F
  574.                 GOTO END
  575.                 :BOOT2
  576.                 REN BOOT2 BOOT3
  577.                 GOTO END
  578.  
  579.                 :BOOT1
  580.                 REN BOOT1 BOOT2
  581.                 GOTO END
  582.                 :ERROR
  583.                 ECHO A BOOT file already exists, please delete
  584.                 ECHO it and retry.
  585.                 :END
  586.  
  587.         When you execute COUNT.BAT, it checks for a file named BOOT? and 
  588.         branches to a label in the batch file, although most of the 
  589.         branching simply renames the BOOT? file to the next level, thus 
  590.         incrementing the counter. In the first pass, the BOOT2 file is 
  591.         created via the instructions at label NO. We make an initial 
  592.         file of BOOT2 because this will have been the first pass. Each 
  593.         additional pass thru the batch file, causes a high numbered 
  594.         BOOT? file to be created, by renaming a previous level. If 
  595.         during the first pass, a BOOT? file is discovered, other than 
  596.         the 3 BOOT? files we want, we branch to the ERROR label and 
  597.         instruct the user to delete it. You can perform tests on as many 
  598.         different branches as you wish. For example, you might count to 
  599.         10, running CHKDSK /F on count 5 and a back up on count 10. Just 
  600.         add additional BOOT? names in the line beginning with FOR, and 
  601.         additional labels after BOOT3 for the additional BOOT? 
  602.         functions. NOTE, the COUNT.BAT file is in the root directory 
  603.         with AUTOEXEC.BAT and BOOT? files.
  604.  
  605.  
  606.  
  607.         DOS 5.0 CHKDSK Meanings
  608.  
  609.         Many users are confused by the DOS 5.0 CHKDSK display. The 
  610.         following is a DOS 5.0 CHKDSK report for a PC with a 40MB hard 
  611.         drive, along with the meaning.
  612.  
  613.         33462272 bytes total disk space
  614.         57344 bytes in 5 hidden files    ────────┤ Hard disk space
  615.         172032 bytes in 74 directories           │ utilization in
  616.         29212672 bytes in 4921 user files        │ bytes
  617.         3975168 bytes available on disk
  618.  
  619.                                                  │ Disk space allocation
  620.                                                  │ units. An allocation
  621.                                                  │ unit is a group of
  622.         2048 bytes in each allocation unit  ─────┤ sectors that DOS
  623.         16339 total allocation units on dis      │ treats as a single
  624.         1941 available allocation units on disk  │ block. It represents
  625.                                                  │ the least amount of
  626.                                                  │ disk space DOS will
  627.                                                  │ allocate to a file.
  628.  
  629.                                                  │ Amount of convention-
  630.         655360 total bytes memory  ──────────────┤ al memory installed 
  631.         511984 bytes free                        │ and available. This
  632.                                                  │ memory is different
  633.                                                  │ from hard disk memory
  634.                                                  │ reported above.
  635.  
  636.         Allocation units are also called CLUSTERS.
  637.  
  638.         A hard drive is much like a floppy disk, except it can hold much 
  639.         more data, and can NOT be removed like a floppy. In addition, a 
  640.         hard is accessed faster than a floppy. RAM, is temporary 
  641.         storage, inside the computer, and goes away each time power is 
  642.         turned off, and must be restored each time your computer is 
  643.         turned back on. This process is called booting.
  644.  
  645.  
  646.  
  647.  
  648.         Emergency Disks
  649.  
  650.         If you are backing up your system regularly, the following 
  651.         information will aid in getting you back up and running quickly. 
  652.         You will need to make a DOS boot disk (if you have an older 
  653.         machine it will be a 360K disk). To make a boot disk, place a 
  654.         new (un-formatted) disk, into drive A: and type "FORMAT A: /S" 
  655.         at your DOS prompt. This will create a bootable disk, with the 
  656.         DOS operating system on it. Now, put the following DOS utilities 
  657.         on this disk :
  658.  
  659.                 FDISK.EXE
  660.                 FORMAT.COM
  661.                 DEBUG.COM   (XT machines only)
  662.  
  663.         If the disk has room, place a copy of your backup program onto 
  664.         the disk (or just the restore portion). If your backup program 
  665.         will NOT fit onto this disk, then you will have to put it onto a 
  666.         separate disk. You might read your back up disk documentation to 
  667.         see if it suggests how to make an emergency restoral disk. Next, 
  668.         you will need a low level formatting program, such as Disk 
  669.         Manager, or for XT machines, you will need to place the DOS 
  670.         DEBUG.COM program on the emergency disk. Mark the disk(s), 
  671.         "Emergency Boot Disk(s)". Now, when your hard drive fails (all 
  672.         eventually do), you'll be able to restore the system. Simply 
  673.         repair or replace the hard drive, pull out your back up disks 
  674.         from your last backup and do the following.
  675.  
  676.                 1) Boot your system from the "Emergency Boot Disk"
  677.                 2) Start the lowlevel formatting program
  678.                 3) Run FDISK to partition the drive
  679.                 4) Run Format to format the drive
  680.                 5) Run your backup programs restore file option
  681.  
  682.         If you are restoring an XT, then replace step two above with :
  683.  
  684.                 2) Start DEBUG, and enter GC800:5 at the "-" prompt
  685.  
  686.         This will lowlevel format an XT machine.
  687.  
  688.         If you backup regularly, getting things going will be much 
  689.         faster and easier than with out regular backups. If you are 
  690.         attempting to restore you system without a backup set, you'll 
  691.         have to have original disks for each application and reinstall 
  692.         each! If you had data, on the broken drive, which must be 
  693.         recovered, you'll have to lay out a big chunk of money to a data 
  694.         recovery service to get the data off the broken drive (and there 
  695.         are NO guarantees the data can all be recovered). By backing up 
  696.         regularly, you need only perform the above 5 steps, with a time 
  697.         of around 2 hours to several hours. If you don't, it may take 
  698.         you months to recover the data you lost!
  699.  
  700.  
  701.  
  702.         Directory Navigation Shortcuts
  703.  
  704.         Save yourself time and keystrokes, by using these directory 
  705.         navigation shortcuts.
  706.  
  707.         If you are in a directory \WP\FILES and wish to go to \WP\DOCS 
  708.         you'd type these lines.
  709.  
  710.                 CD \
  711.                 CD WP
  712.  
  713.                 CD DOCS
  714.  
  715.         These three lines can be replaced with one:
  716.  
  717.                 CD ..\DOCS
  718.  
  719.         DOS supplies us with a directory entry "..", which references 
  720.         the previous directory level. By Type "CD .." we go back one 
  721.         level. By adding the "\DOCS" to the tail of this string, we can 
  722.         navigate the entire change in one command. First, DOS moves back 
  723.         the one level (now in \WP), then DOS moves forward one level to 
  724.         the directory DOCS (now in \WP\DOCS).
  725.  
  726.         Another interesting aspect of this function is in navigating 
  727.         multi-level directories. If you are in the following directory :
  728.  
  729.         \WORD\FILES\LETTERS\APRIL
  730.  
  731.         And wanted to go to the directory \WORD\FILES, you'd normally 
  732.         type two lines : 
  733.  
  734.                 CD \
  735.                 CD WORD\FILES
  736.  
  737.         Or even the single line "CD \WORD\FILES" to combine the two 
  738.         commands into one. There is a shorter way, simply type the 
  739.         following : CD ..\..     You're there !
  740.  
  741.  
  742.  
  743.         Batch File CALLS Using DOS Before Version 3.3
  744.  
  745.         In DOS 3.3 and up, there is a new command "CALL", which will 
  746.         execute another batch file, then return to the original batch 
  747.         file, starting at the line after the "CALL". For instance :
  748.  
  749.                 ECHO OFF
  750.                 CLS
  751.                 CALL AUTO
  752.                 MENU
  753.  
  754.         Would call the batch file "AUTO", then return an start a MENU. 
  755.         This function can be emulated using earlier DOS versions, and 
  756.         without executing another COMMAND.COM shell! To do this involves 
  757.         a little forethought and planning. Taking the above example, we 
  758.         create a batch file, adding a couple of lines.
  759.  
  760.                 ECHO OFF
  761.                 IF %RETURN%*==* GOTO START
  762.                 GOTO %RETURN%
  763.                 :START
  764.                 CLS
  765.                 SET RETURN=RETURN
  766.                 AUTO AUTOEXEC
  767.                 :RETURN
  768.                 MENU
  769.  
  770.         After our ECHO OFF (halt echoing), we check to see if the 
  771.         variable (DOS Environ) is set, and if so we assume it is set to 
  772.         a label in the current batch file, AUTOEXEC. If there is NOT a 
  773.         label, we branch to the normal entry and clear the display. 
  774.         However, if RETURN has a value, we branch to that label, 
  775.         assuming the label is in the current batch file AUTOEXEC. After 
  776.         clearing the screen, we set our return label to RETURN and start 
  777.         the AUTO batch file.
  778.  
  779.  
  780.         The batch file AUTO will then have these lines:
  781.  
  782.                 {your batch file commands}
  783.                 %1%
  784.  
  785.         The last line, returns control to the original batch file. The 
  786.         AUTOEXEC after AUTO in our first batch file, is will replace the 
  787.         %1 parameter ! When we return, we will automatically return to 
  788.         the label "RETURN" in the first batch file, then we can start 
  789.         the menu.
  790.  
  791.  
  792.  
  793.         Nested Batch Files Save Time
  794.  
  795.         If you want to beef up your batch files, use the DOS COMMAND /C 
  796.         and CALL commands, to create nested batch files that call up one 
  797.         batch file from within another. Without these commands, an 
  798.         executing batch file that summons another will execute the 
  799.         second file and return to a DOS prompt, without completing the 
  800.         original batch file. With DOS 3.3 and higher, CALL, an internal 
  801.         command, can be used to invoke a second batch file, like this :
  802.  
  803.                 DATE
  804.                 CALL TELECOM
  805.                 WP
  806.  
  807.         In this example, which loads a communications program, then a 
  808.         wordprocessor, the CALL command invokes the TELECOM batch file 
  809.         and returns control to the original batch file, which then 
  810.         executes the WP command. If you are using DOS earlier than 3.3, 
  811.         then a different method must be used. The following batch 
  812.         example will perform as the above, for DOS versions earlier than 
  813.         3.3 :
  814.  
  815.                 DATE
  816.                 COMMAND /C TELECOM
  817.                 WP
  818.  
  819.         This approach does have disadvantages. Unlike the DOS 3.3+ call 
  820.         command, COMMAND /C loads another copy of COMMAND.COM to execute 
  821.         the second batch file. When COMMAND.COM terminates, it passes 
  822.         control back to the first batch file, which then executes the 
  823.         final instruction WP. Because each nested batch file has it's 
  824.         own copy of COMMAND.COM , memory usage will be high, and the 
  825.         number of nested calls will be much less than later DOS versions 
  826.         with the CALL command. You can use the CALL and COMMAND /C 
  827.         approach, even from an AUTOEXEC batch file.
  828.  
  829.  
  830.        Tutorial finished. Have you registered PC-Learn to receive your
  831.        bonus disks? Registration is encouraged. Shareware works on the
  832.        honor system! Send $25 to Seattle Scientific Photography, 
  833.        Department PCL6, PO Box 1506, Mercer Island, WA 98040. Latest 
  834.        version of PC-Learn and two bonus disks shipped promptly!
  835.  
  836.  
  837.  
  838.  
  839.  
  840.