45
5
I'm writing a bat script in which I invoke a program (such as javac). For simplicity, I want to check if the command exists before I run it. i.e. If the command exists in PATH.
For example,
if (my_command.exe is a recognized command) then (
my_command.exe my_args
) else (
REM Output was probably "'my_command.exe' is not recognized as an internal or external command, operable program or batch file."
REM Do not run my_command.exe
)
What's the best way to do this in Windows?
How will you "recognize" your command ? – Rook – 2010-08-13T12:56:10.947
In MS-DOS (true DOS) this was rather simple; you just checked the existence of an exe file in c:\dos; but even then the question remains. – Rook – 2010-08-13T12:57:02.993
Sorry for the confusion. I meant essentially a command prompt in Windows. If I type "lkajsflksajdfj" I want to detect it isn't a command. If I type "notepad.exe", it's OK. – user46097 – 2010-08-13T13:18:36.697