The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,953 other followers

Archive for July 8th, 2014

which.bat (in case I don’t have CygWin on a system)

Posted by jpluimers on 2014/07/08

Small batch file that shows you the files on the path. It is a simple version that does not take into account built-in commands of cmd.exe, DOSKEY macros or PATHEXT environment variable: it just matches a name of an executable. Rob van der Woude has a complete which.bat (text version here) that does take into account all of the above. This is the poor man’s version:

@echo off
for %%f in (%1) do @echo. %%~$PATH:f
goto :eof

It uses this little trick from the FOR command:

%~$PATH:I Searches the directories listed in the PATH environment variable and expands %I to the fully qualified name of the first one found. If the environment variable name is not defined or the file is not found by the search, this modifier expands to the empty string.


Posted in Batch-Files, Development, Scripting, Software Development | Leave a Comment »

%d bloggers like this: