In tip 7585, Whence.bat script locates specified files in a path,
I presented a complex script with a number of configurable options.
I have scripted InPath.bat to simply return the fully qualified file name of the first occurence of the specified file in your path.
The syntax for using InPath.bat is:
InPath FileName.ext
where FileName.ext is a file name with extension.
Examples
InPath notepad.exedisplays
C:\WINDOWS\SYSTEM32\notepad.exe
InPath notepad
displays nothing.
InPath abcd.efg
displays nothing.
InPath regedit.exe
displays
C:\WINDOWS\regedit.exe
To use the ouput of InPath.bat in your script:
set FQFN=None for /f "Tokens=*" %%a in ('InPath FileName.ext') do ( set FQFN=%%a )NOTE: If FQFN EQU "None", the file was not found in your path.
InPath.bat contains:
@echo off if \{%1\}==\{\} @echo Syntax: InPath FileName.ext&goto :EOF for /f "Tokens=*" %%F in ('@echo %1') do ( If "%%~dp$PATH:F" NEQ "" @echo %%~dp$PATH:F%%~F )
0 comments
Hide comments