@echo off&setlocal ENABLEEXTENSIONS DISABLEDELAYEDEXPANSION&goto main :chkdir root app subdirs FOR %%b IN (.;%PathExt%) DO IF "%g_d%"=="" IF EXIST "%~1\%~2%%b" ( IF NOT EXIST "%~1\%~2%%b\" set "g_d=%~1" ) IF "%~3%g_d%"=="1" for /D %%a IN ("%~1\*") DO call %0 "%%~a" %2 %3 @goto :EOF :main set ERRORLEVEL=&set g_ec=2&set g_d=&set g_tok=1&set g_cmd=call if "%~1"=="*" (shift&set g_tok=2&set "g_cmd=start """) else if /I "%~1"=="*WhatIf" (shift&set g_tok=2&set g_cmd=echo) if "%~1"=="" (echo.&echo.FindExec v0.5 - Anders Kjersem&set g_ec=234&goto q) FOR %%a IN (.;"%Path:;=";"%") DO call :chkdir %%a %1 0 FOR %%a IN (a b c d e f g h i j k l m n o p q r s t u v w x y z) DO call :chkdir %%a: %1 1 IF NOT "%g_d%"=="" FOR /F "tokens=%g_tok%,*" %%A IN ("%*") DO setlocal ENABLEDELAYEDEXPANSION&( setlocal DISABLEDELAYEDEXPANSION&(%g_cmd% "%g_d%\%~1" %%B)&endlocal&set g_ec=!ERRORLEVEL! ) :q @%COMSPEC% /C exit %g_ec% >nul