- which.cmd
@Echo Off If "%1"=="" ( Echo.Usage: %~nx0 COMMAND Echo.Write the full path of COMMAND^(s^) to standard output. Exit /b 0 ) For %%i In (%PATHEXT%) Do Call :EXIST_THEN_ECHO %1%%i && Exit /b 0 Echo.%~nx0: no %1 in (%PATH%) Exit /b 1 :EXIST_THEN_ECHO If Not Exist "%~1\" If Exist "%~1" Echo..\%~1& Exit /b 0 If Not "%~$PATH:1"=="" Echo.%~$PATH:1& Exit /b 0 Exit /b 1
IE8 や Firefox3 などの data スキーマに対応しているブラウザなら
参照
- help call
修正履歴
- カレントフォルダを先に確認 (2011.08.15)
:EXIST_THEN_ECHO
If Not "%~$PATH:1"=="" Echo.%~$PATH:1& Exit /b 0
If Not Exist "%~1\" If Exist "%~1" Echo..\%~1& Exit /b 0
↓
:EXIST_THEN_ECHO
If Not Exist "%~1\" If Exist "%~1" Echo..\%~1& Exit /b 0
If Not "%~$PATH:1"=="" Echo.%~$PATH:1& Exit /b 0