So, after a lot of customization, and thanks to the help of @Andriy M, it finally works.
@ECHO off CALL :isInternalCommand dir dirInternal ECHO is dir internal: %dirInternal% CALL :isInternalCommand find findInternal ECHO is find internal: %findInternal% exit /b 0 :isInternalCommand SETLOCAL MKDIR %TEMP%\EMPTY_DIR_FOR_TEST > NUL 2>& 1 CD /D %TEMP%\EMPTY_DIR_FOR_TEST SET PATH= %~1 /? > NUL 2>&1 IF ERRORLEVEL 9009 (ENDLOCAL SET "%~2=no" ) ELSE (ENDLOCAL SET "%~2=yes" ) GOTO :EOF
OLD SOLUTION
You can use where . If this fails, the command is probably internal. If this succeeds, you will get an executable path that proves that it is not internal.
C:\Users\user>where path INFO: Could not find files for the given pattern(s). C:\Users\user>where find C:\Windows\System32\find.exe
EDIT: As the comments suggest, this may not be the best solution if you are looking for portability, not just research. So here is another possible solution.
Set %PATH% nothing, so HELP cannot find anything, and then run HELP on the command you are trying to verify.
C:\Users\user>set PATH= C:\Users\user>path PATH=(null) C:\Users\user>%WINDIR%\System32\help del Deletes one or more files. DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names [...] C:\Users\user>%WINDIR%\System32\help find 'find' is not recognized as an internal or external command, operable program or batch file.
This may still fail if the team has no help.
EDIT 2: Nothing, this won't work either. Both cases return %ERRORLEVEL%=1 .
source share