We Recommend

bash Cookbook: Solutions and Examples for bash Users bash Cookbook: Solutions and Examples for bash Users
bash Cookbook teaches shell scripting the way Unix masters practice the craft. It presents a variety of recipes and tricks for all levels of shell programmers so that anyone can become a proficient user of the most common Unix shell -- the bash shell -- and cygwin or other popular Unix emulation packages.


Posted By

jimfred on 11/27/08


Tagged

which


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

meetneps


which command


Published in: DOS Batch 


This which.bat command works like Linux/bash 'which'

Save the Source as file which.bat and place it somewhere in the executable path.

Example usage: "which notepad.exe" results in "C:\WINDOWS\system32\notepad.exe". Note the .exe - 'which notepad' (without the .exe) results in "notepad not found in path"

  1. @Set Which=%~$PATH:1
  2. @if "%Which%"=="" ( echo %1 not found in path ) else ( echo %Which% )

Report this snippet 

Comments

RSS Icon Subscribe to comments
Posted By: Vordreller on March 21, 2009

This only seems to work for files located in the WINDOWS map.

You need to login to post a comment.