windows下bat脚本相当于linux的which

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

你可能感兴趣的:(windows下bat脚本相当于linux的which)