USE and UNUSE 6.2 are freeware utility programs for adding and removing directories from your path, without retyping the entire path.
USE will add a directory to the PATH; UNUSE removes a directory.


Here is the command syntax of USE and UNUSE:

USE [[drive:]path[;...]]  [/E] [/Q] [/?]

Append new directories to the front of the search path.

Execution of USE without parameters displays the current path.

/E   Append to end of the path
/Q   Quiet, does not display new path
/?   Display this help screen



UNUSE [[drive:]path[;...]] [/Q] [/?]

Deletes directories from the search path.

Execution of UNUSE without parameters displays the current path.

/Q   Quiet, does not display new path.
/?   Display this help screen.


Three suggested applications of USE and UNUSE:

USE and UNUSE make batch files easier to maintain.  Since the PATH command sets the entire path, every batch file that uses the PATH must be updated when the system path changes.  USE and UNUSE avoid that problem by only changing specific portions of the path.

USE and UNUSE reduce the I/O traffic on disks and LANS.  Every additional directory on the path creates an additional I/O request.  Unsuccessful searchs produce a noticable delay on a hard disk and increased traffic on a LAN.  USE allows you add directories to the path only when needed.  Since DOS stops searching the path when a file is found, USE moves the directory to the front of path.  (USE does this to both new and existing directories on the path.)  The '/E' parameter will move seldom used directories to the end of the path.

USE and UNUSE increase the usable length of the path.  All dos command lines are limited to 127 bytes.  Five bytes are needed for the PATH command, so 122 bytes is the longest possible path for the PATH command.  USE appends to the path, so the 127 byte limit can be worked around with multiple USE commands.  With USE, the size of the path is limited only by the available environment size.


Operational Notes:
By default, USE will put the new directory at the front of the
path.  Starting USE with the switch "/E" will put the directory
at the end of the path.  If USE is given a directory already on 
the path, that directory will be moved to the front of the path, 
or the end if the "/E" switch is used.

USE and UNUSE work on the current command processor, and any changes made with USE and UNUSE will apply only to the current environment.  For example, enter COMMAND at the DOS prompt to start a new command processor.  Now enter USE C:\TEMP.  When you type EXIT to remove the secondary command processor, all changes are also removed.

USE and UNUSE return the following error level codes:
  0 = Normal, directory added or removed
  1 = Directory was already on path (USE only)
  2 = Nothing was done 
  4 = Help display
  5 = Command failed

USE and UNUSE have been tested with DOS versions 2, 3, 4, 5, 6, and 6.2; and Windows 3.0 and 3.1.  However, USE and UNUSE change the environment area of DOS, and you should test it throughly on your machine, especially if you use any TSR programs or alternate command processors.


Program synopsis:
USE and UNUSE begin by parsing the command line to see if the path should be changed.  Next the program prefix chain is walked back to the start, and memory is scanned for "markers" to the enviroment.  The environment location is verified and the environment size is detirmined.  If there is enough room, the path is changed by removing the old path, packing any other environment variables, and then adding the new path to the end of the enviroment variables.  (Type SET at the DOS prompt to see all your environment variables)


Known limitations of USE and UNUSE:
USE and UNUSE do not work with 4DOS or NDOS, as far as I know.


Examples:

C:\>Rem   Print the current path.
C:\>path
PATH=C:\UTILITY;C:\NORTON;C:\BATCH;C:\DOS

C:\>Rem   Starting USE without a directory prints the current path.
C:\>use
PATH=C:\UTILITY;C:\NORTON;C:\BATCH;C:\DOS

C:\>Rem   Add c:\test to the beginning of the path.
C:\>use c:\test
PATH=C:\TEST;C:\UTILITY;C:\NORTON;C:\BATCH;C:\DOS

C:\>Rem   Remove c:\test from the path.
C:\>unuse c:\test
PATH=C:\UTILITY;C:\NORTON;C:\BATCH;C:\DOS

C:\>Rem   C:\DOS is already on the path; it is moved to the front.
C:\>use c:\dos
PATH=C:\DOS;C:\UTILITY;C:\NORTON;C:\BATCH

C:\>Rem   C:\utility is on the path; /E moves to the back.
C:\>use c:\utility /E
PATH=C:\DOS;C:\NORTON;C:\BATCH;C:\UTILITY

C:\>Rem   C:\ is not on the path; UNUSE just prints the path.
C:\>unuse c:\
PATH=C:\DOS;C:\NORTON;C:\BATCH;C:\UTILITY


Alternatives to USE and UNUSE:
A .BAT file can approximate the function of the USE program, 
but without error checking.  Here is the .BAT file:

PATH=%1;%PATH%

The %1 will be replaced with first parameter on the command line, 
the ";" will be literally inserted, and %PATH% will be replaced with 
the current path.  However, unlike USE, this method is still limited by 127 command line limit.



This software may be freely used, but not sold for profit.  The user assumes all risk associated with the use of software.  Please include this documentation when distributing this software.


Version 6.2 changes:
Added /Q to omit messages from USE/UNUSE.

Fixed bug that caused 'USE /' to incorrectly report " Out of Environment Space'.

Tested with DOS 6.2

(Version 5.1, dated 9/11/91, will also works with DOS 6.0 and 6.2.  Older versions should be replaced.)


Acknowledgements:

Thanks to Peter Neuhaus for his suggestions.


Copyright 1991,1993 James Gregg Haley

October 31, 1993
James Haley
71121,3644
