Category : Batch File Utilities - mostly for DOS
Archive   : BATUTIL.ZIP
Filename : GETPATH.DOC
files - GETPATH.DOC - this file
GETPATH.EXE - MSDOS 2.0 or higher executable program
GETPATH.MOD - Logitech Modula-2 source code
UTILITY.DEF - additional source code referenced in GETPATH.MOD
UTILITY.MOD
Purpose: To allow the PATH to be reset temporarily and then restored.
Description: Gets current value of environment variable PATH and writes
out commands to restore that PATH at a later point. Default output is
to file RESTPATH.BAT on current default drive. RESTPATH can later be
used to restore a PATH that has been temporarily altered. Calling
format is:
GETPATH TmpPath [Output File {may include drive and path}]
where TmpPath is the path that PATH is going to be changed to. There
is no default value for TmpPath. If only one command line parameter
is passed to the program, it is assumed to be TmpPath. If no command
line parameters are passed to the program, it just exits without doing
anything. If excess parameters beyond Output File are passed to the
program, they are just ignored and the program treats the first two
as TmpPath and Output File. If Output File is included, but is not
preceded by a drive, e.g., a:file, then drive written to will be the
current default drive.
Output written to Output File consists of the following:
echo off
set PATH={Value of PATH at first call to GETPATH}
cls
Calls to GETPATH once PATH has been changed to TmpPath will result
in no action. Calling RESTPATH will restore the value of PATH present
when GETPATH was first called. The output can be sent to any legal file.
The success or failure of GETPATH can be evaluated by inspecting the
ERRORLEVEL value maintained by DOS after calling GETPATH. The values
of ERRORLEVEL and corresponding completion status are the following:
ERRORLEVEL = 0 -> normal completion, no error
ERRORLEVEL = 1 -> unable to create specified output file
ERRORLEVEL = 2 -> missing command line parameters
ERRORLEVELs 1 and 2 are both fatal and result in failure of GETPATH
to perform its task.
SAMPLE USAGE IN .BAT FILE
echo off {so each command not echoed to screen}
getpath a:\;a:\itrain {call getpath with default output}
if ERRORLEVEL 2 goto err2 {test ERRORLEVEL}
if ERRORLEVEL 1 goto err1
set path=a:\;a:\itrain {reset PATH temporarily}
.
.
In here do whatever your .bat file does
.
.
goto OK {skip past error messages}
:err1 {ERRORLEVEL = 1 message}
echo ERROR - getpath unable to create file
goto quit {skip everything else}
:err2 {ERRORLEVEL = 2 message}
echo ERROR - getpath missing command line parameters
goto quit {skip everything else}
:OK {everything went OK}
restpath {restore previous path}
:quit
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/