Home‎ > ‎

Which/whereis for windows

posted Jul 28, 2011, 12:33 AM by Pieter-Bas IJdens
As someone who grew up using Unix systems, one of the tiny little tools I really miss in Windows is the which/whereis command. I am sure there are tens of ways that I am not aware of for doing the exact same thing, but I still would like to share my quick-hack solution:

Create a batch file called 'which.bat' in C:\Windows\System32 with the following contents:
@echo off
SET FOUND_IN=%~dp$PATH:1
SET FILENAME=%~n1%~x1

set RESULT=%FOUND_IN%%FILENAME%
if not exist "%FOUND_IN%\%FILENAME%" set RESULT=Not found: %FILENAME%

echo %RESULT%

Proof that it works:
C:\>which foo.bar
Not found: foo.bar

C:\>which ildasm.exe
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\ildasm.exe

Comments