- Aug
- 2,152
- 92
On occasion, I have programs in my path that conflict with other programs that I am wanting to use.
For example, the hbmk2.exe program in c:\hb32\bin has it's own version of the MinGW compilers, while I use the MinGW compiler in C:\MinGW for other development applications.
There are also times when the Gtk toolkit and assorted GNOME libraries causes problems when doing .NET development vs. Mono development.
I can use the eset command to edit the path, but I have developed a .BTM to make it easier.
This is by no means a finished, or polished .BTM, but it does what I need it to do.
I am sure that many lines could be eliminated by the use of TPipe, and if you are so inclined, please feel free to show how easy the same thing can be accomplished with TPipe, as I would also like to know.
Anyway, here is my non-TPipe solution;
Joe
For example, the hbmk2.exe program in c:\hb32\bin has it's own version of the MinGW compilers, while I use the MinGW compiler in C:\MinGW for other development applications.
There are also times when the Gtk toolkit and assorted GNOME libraries causes problems when doing .NET development vs. Mono development.
I can use the eset command to edit the path, but I have developed a .BTM to make it easier.
This is by no means a finished, or polished .BTM, but it does what I need it to do.
I am sure that many lines could be eliminated by the use of TPipe, and if you are so inclined, please feel free to show how easy the same thing can be accomplished with TPipe, as I would also like to know.
Anyway, here is my non-TPipe solution;
Code:
:: PATHMAN.BTM
:: Removes a semicolon-separated directory from the path.
::
:: Similar to what the PATHMAN.EXE utility does,
:: which is part of the Windows Server 2003 Resource Kit,
:: which does not work on Windows Vista.
::
:: TCC 16.03.54 Windows Vista [Version 6.0.6002]
:: TCC Build 54 Windows Vista Build 6002 Service Pack 2
:: Joe Caverly
::
@setlocal
@echo off
::
:: How many Semi-Colons are in the path?
::
set SColons=%@count[;,%path]
set SColons=%@inc[%SColons]
::
:: pathlist is an alias
:: Ref: http://jpsoft.com/forums/threads/pathlist-alias.5138/
::
If not IsAlias pathlist alias pathlist=`echo %=n %@replace[;,%=n ,%path]`
::
:: Read the path into an array
::
set pathlist=%@unique[]
pathlist > %pathlist
setarray /r %pathlist aPath
::
:: Display a list of the directories in the path
::
do kount=0 to %SColons
if %@len[%aPath[%kount]] gt 0 echo %aPath[%kount]
enddo
::
:: Ask the user what directory they want removed from the path
::
echo %@select[%pathlist,0,0,%_rows,%_columns,Select an option] > nul
set theline=%@dec[%SELECT_LINE]
::
:: If the Esc key was pressed...
::
iff %theline eq -1 then
echo Cancel
goto eoj
endiff
echo Line Selected: %theline
::
:: Create a new path
::
echo %aPath[%theline]
set temppath=%@unique[]
echos set Path= > %temppath
do kount=0 to %SColons
iff %@len[%aPath[%kount]] gt 0 then
iff %aPath[%kount] eq %aPath[%theline] then
echo %aPath[%kount]
else
echos %@ltrim[" ",%aPath[%kount]]; >> %temppath
endiff
endiff
enddo
echo %@lines[%temppath] > nul
::
:: Number of bytes in the path, minus the trailing Semi-Colon
::
set NoComma=%@dec[%_LINES_MAXLEN]
::
:: Remove the trailing Semi-Colon
::
set newpath=%@unique[]
head /C%NoComma %temppath > %newpath
::
:: Display the new path
::
type %newpath
defer %@line[%newpath,0]
:eoj
if exist %newpath del /q %newpath
if exist %temppath del /q %temppath
if exist %pathlist del /q %pathlist
unsetarray aPath
endlocal
Joe