Command line scripts stop executing when they encounter an invalid command. For example: echo test | sortz 1> out.txt 2>&1 Sort is spelled incorrectly and the cmd file stops executing. It may be desireable at times to test whether a command is avalable without terminating the script. The following code tests for sorta availability and reports an error if not. echo test | cmd /q /k"sorta" 1> out.txt 2>&1 type out.txt | find /I "not recognized" if not errorlevel 1 echo Sorta.exe not available, copy from another system: >> "%ErrorLog%" if not errorlevel 1 goto :Status
|