You can use something very similar
%command% >nul 2>&1 || ( echo "Error: command not found" exit /b 1 )
Of course, this will actually execute the command, but most commands will not do anything without the correct parameters. If you want to be more confident, you can use %command% /? >nul 2&1 %command% /? >nul 2&1 . This will try to bring up the help page for the command without executing it.
Update: To avoid running the entire command, consider where.exe . It comes bundled with Vista and Windows 7. For other operating systems, you can download it. See this post on how to download it.
After that, you can run it with /Q to avoid additional output. A return code of 0 means that the command was found. I once discovered that the where command requires you to provide an extension.
At the other end, there is a lengthy discussion here about a batch βone-linerβ that works without the specified extension (but does not actually execute when you specify the extension)
source share