which.bat
@echo off & setlocal enabledelayedexpansion
if "%1" == "" (
echo which可以查找PATH路径中是否包含指定程序
echo 用法:which 程序名
goto :ext
)
set pathstr=%PATH%
@echo -------------------------
: findfile
FOR /F " tokens=1* delims=;" %%i IN ("!pathstr!") do (
set p=%%i
if "!p:~-1!" NEQ "\" (
set p=!p!\
)
if exist !p!%1 (
@echo 存在目录于:%%i
)
set pathstr=%%j
goto findfile
)
@echo -------------------------
:ext
@echo on