I have always missed the which utility of Unix under Windows, which doesn't seem to have built-in equivalent. So, when I came across batch script parameter modifiers while browsing Windows shell scripting, I decided to write a Windows equivalent of which:
@echo off rem -------------------------------------------------------- rem File: which.cmd rem Description: Windows equivalent of Unix which command rem Author: Pankaj Kumar rem Copyright 2004 Pankaj Kumar. All Rights Reserved. rem License: This software is available under GPL rem --------------------------------------------------------- setlocal if "%1" == "" goto noArg
set fullpath=%~$PATH:1 if "%fullpath%" == "" goto notFound echo Found in PATH: %fullpath% goto end
:noArg echo No Argument specified goto end
:notFound echo Argument "%1" not found in PATH
:end endlocal
To use this command, either do a Copy-Paste of the above source code (but, beware of the formatting tags) or download which.cmd.