echo off
echo.
echo ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
echo ³ Delete a directory from the path variable         ³
echo ³ By Prof. Timo Salmi, ts@uwasa.fi, Sun 30-Aug-1992 ³
echo ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
echo.

if "%1"=="" goto _help
if "%2"=="" goto _makeaux
echo The extra parameters are ignored: %2 %3 %4 %5 %6 %7 %8 %9

rem Build the auxiliary batch that DELPATH.BAT needs to call
:_makeaux
echo rem SETVAR.BAT, An auxiliary batch needed for DELPATH.BAT> setvar.bat
echo if "%%_newpath%%"=="" goto _new>> setvar.bat
echo set _newpath=%%_newpath%%;%%1>> setvar.bat
echo goto _out>> setvar.bat
echo :_new>> setvar.bat
echo set _newpath=%%1>> setvar.bat
echo :_out>> setvar.bat

rem Change the directory-name parameter to upper case
set _stash=%path%
path %1
set _dir=%path%
path %_stash%
set _stash=

rem Check that the auxiliary file setvar.bat is available
if exist setvar.bat goto _build
echo Could not make the auxiliary setvar.bat (disk read-only?)
goto _out

rem Build the path anew
:_build
set _newpath=
for %%d in (%path%) do if not "%%d"=="%_dir%" call setvar %%d
path %_newpath%
goto _out

:_help
echo Usage: DELPATH [Directory]
echo.
echo MsDos version 3.30 required.
echo.
echo If you get an "Out of environment space" message, increase your
echo environment space by using shell configuration in config.sys:
echo Example: shell=c:\bin\command.com /e:1024 /p
echo.
echo Current path %path%
goto _out2

:_out
set _newpath=
set _dir=
if exist setvar.bat del setvar.bat > nul
path
:_out2
echo on
