How to test if an executable exists in the %PATH% from a windows batch file?

后端 未结 9 613
暖寄归人
暖寄归人 2020-12-22 20:33

I\'m looking for a simple way to test if an executable exists in the PATH environment variable from a Windows batch file.

Usage of external tools not provided by th

9条回答
  •  天命终不由人
    2020-12-22 21:02

    @echo off
    set found=
    set prog=cmd.exe
    for %%i in (%path%) do if exist %%i\%prog% set found=%%i
    echo "%found%"
    if "%found%"=="" ....
    

提交回复
热议问题