Is there an equivalent of 'which' on the Windows command line?

后端 未结 26 2120
悲哀的现实
悲哀的现实 2020-11-22 00:40

As I sometimes have path problems, where one of my own cmd scripts is hidden (shadowed) by another program (earlier on the path), I would like to be able to find the full pa

26条回答
  •  星月不相逢
    2020-11-22 00:42

    This batch file uses CMD variable handling to find the command that would be executed in the path. Note: that the current directory is always done before the path) and depending on which API call is used other locations are searched before/after the path.

    @echo off
    echo. 
    echo PathFind - Finds the first file in in a path
    echo ======== = ===== === ===== ==== == == = ====
    echo. 
    echo Searching for %1 in %path%
    echo. 
    set a=%~$PATH:1
    If "%a%"=="" (Echo %1 not found) else (echo %1 found at %a%)
    

    See set /? for help.

提交回复
热议问题