Skip to content

Instantly share code, notes, and snippets.

@AyrA
Created November 2, 2017 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AyrA/63dfb4683587230d9beb85eebfdb203e to your computer and use it in GitHub Desktop.
Save AyrA/63dfb4683587230d9beb85eebfdb203e to your computer and use it in GitHub Desktop.
where command on Windows
@ECHO OFF
REM Store this anywhere in your PATH.
SETLOCAL
SET FULL=%~$PATH:1
IF "%FULL%"=="" GOTO NF
GOTO PRINT
:PRINT
ECHO %FULL%
GOTO END
:NF
IF "%2"=="" GOTO TRYEXT
GOTO END
SET FULL=(not found)
GOTO PRINT
:TRYEXT
FOR %%I IN (%PATHEXT%) DO CALL "%~0" "%~1%%I" QQ
GOTO END
:END
ENDLOCAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment