Using the command to return your %PATH%, one line at a time, I have scripted IsInPath.bat
to test if a folder is in your %PATH%.
The syntax for using IsInPath.bat is:
call IsInPath FolderPath Answer
Where FolderPath is the folder path that you wish to check and Answer is a call directed environment variable that will contain a Y if the FolderPath is in the %PATH%, or an N if the FolderPath is NOT in the %PATH%.
NOTE: You can use Pathman.exe to add the FolderPath to the %PATH%.
IsInPath.bat contains:
@echo off if \{%2\}==\{\} @echo Syntax: IsInPath Folder Answer&goto :EOF setlocal ENABLEDELAYEDEXPANSION set folder=%1## set folder=%folder:"=% set folder=%folder:;##=##% set folder=%folder:\##=% set folder=%folder:##=% set ans=N for %%f in ("%PATH:;=" "%") do ( for /f "Tokens=*" %%a in ('@echo %%f^|Find /I') do ( set ans=Y ) if "!ans!" EQU "N" for /f "Tokens=*" %%a in ('@echo %%f^|Find /I%Folder%\ ') do ( set ans=Y ) ) endlocal&set %2=%ans%%Folder%
0 comments
Hide comments