Lollipop

Welcome to PcCare.com

Command line script stops

 

 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

 

 

DISCLAIMER: It is assumed that users are familiar with the operating system they are using and comfortable with making the suggested changes. PcCare.com will not be held responsible if changes you make cause a system failure.

Please review our Terms of Service and Privacy statement before initiating service or using this site. Microsoft® and the Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. PcCare Site Map. About Us