for %%X in (myExecutable.exe) do (set FOUND=%%~$PATH:X) if defined FOUND ...
If you need this for different extensions, just PATHEXT :
set FOUND= for %%e in (%PATHEXT%) do ( for %%X in (myExecutable%%e) do ( if not defined FOUND ( set FOUND=%%~$PATH:X ) ) )
Maybe this is so, where also already exists on older versions of Windows, but I donโt have access to one, so I canโt say. The following also works on my machine:
where myExecutable
and returns with a non-zero exit code if it cannot be found. In the package, you probably also want to redirect the output to NUL .
Keep in mind
Parsing in batch ( .bat ) files and on the command line is different (because batch files have %0 - %9 ), so you have to double % there. This is not necessary on the command line, so just %X for variables
Joey Jan 24 '11 at 12:10 2011-01-24 12:10
source share