Using the technique from tip 3579,
Erik Remmelzwaal
has scripted Whence.bat.
The syntax for using Whence.bat is:
Whence \[-p pathvar\] file1 \[file2 ... filen\]
where:
-p pathvar specifies an environment variable that contains folder paths. If omitted, the PATH environment variable is used.
Filex is one or more files that you wish to locate, specified with or without their extension.
NOTE: I have amended the script to use the executable extensions in the PATHEXT environment variable.
NOTE: If you specify a Filex without an extension, files with any executable extension, and no extension, are located.
NOTE: If you specify a Filex with an extension, only Filex is tried.
Example:
whence kernel32.dll returns C:\WINDOWS\SYSTEM32\KERNEL32.DLL whence regedit notepad explorer returns C:\WINDOWS\REGEDIT.EXE C:\WINDOWS\SYSTEM32\NOTEPAD.EXE C:\WINDOWS\explorer.exe whence sleep filever returns C:\Program Files\Windows Resource Kits\Tools\sleep.exe C:\Program Files\Support Tools\filever.exeWhence.bat contains:
@echo off setlocal if _%1_ goto :error set P=PATH if not %1
-p goto :doit shift if _%1_ goto :error set P=%1 shift if _%1
_ goto :error :doit set ext=%PATHEXT:;= % :next_file set file=%1 set files=%files% %file% call :exts %ext% shift if not _%1_ goto :next_file for %%F in (%files%) do ( if not _%%~$%P%:F
_ echo %%~$%P%:F ) goto :end :exts if _%1 == _ goto :EOF set files=%files% %file%%1 shift goto exts :error echo usage: %0 \[ -p pathvar \] file ... :end endlocal
0 comments
Hide comments