Hi,
I use the “External (errorlevel)” check with success. If fact, it’s one of my favorite checks because it allows to check “everything I want, as far as I can do a command line check”. I use it with CMD-files and PS1-files. Not with BAT-files, but in most cases you can just rename the BAT into a CMD file. I have 2 dummy batches (CMD and PS1) which I use to troubleshoot the check in SA : 1. AlwaysError5.cmd exit /B 5 2. AlwaysError5.ps1 exit 5 My config: · SA version 7.2.2628 · Win2012 · External (errorlevel) check, Alarm when MyBatchFile.cmd is <> from 0, Kill the external application when not stopped in time=ON, Timeout=5 sec. Kind regards, Pieter From: Servers Alive Discussion List [mailto:[email protected]] On Behalf Of dirk Sent: woensdag 9 december 2015 20:31 To: Servers Alive Discussion List Subject: RE: [SA-list] ErrorLevel AGAIN I think the answer is simple. Servers Alive can capture the ERRORLEVEL set by the application that is actualy executed. And to execute a .BAT file the OS will (behind the scene) launch the command interpreter and this command interpreter will execute your BAT file. The errorlevel we get back in Servers Alive is the one that is set by the command interpreter, not the one by the .BAT file executed within the command interpreter. If you start a command prompt and then the .BAT file, the OS can directly execute the .BAT without having to start another command interpreter. And then it's possible to see the actual errorlevel that is returned by the .BAT file. I personaly don't see a way to get the errorlevel back into SA when the OS is not returning it via the command interpreter back to the actual caller (SA). So the answer is (I think) it's not possible with a .BAT file. -------------------------------------------------------------------------------- From: Servers Alive Discussion List [mailto:[email protected] (mailto:[email protected])] On Behalf Of Jason Passow Sent: Wednesday, December 09, 2015 6:15 PM To: Servers Alive Discussion List Subject: Re: [SA-list] ErrorLevel AGAIN Full path to the .bat file. C:\Program Files (x86)\CountError\CountError.bat no quotes or extra characters. The batch file is running because it writes results to a file (output.txt). That file is changing but the errorlevel is returned as 0 every time. Jason Passow Network Administrator http://www.mwsco.com (http://www.mwsco.com) [email protected] (mailto:[email protected]) ph: (507) 494-5178 fax: (507) 454-8104 Mississippi Welder Supply Co., Inc. Please consider the environment before printing this email. ____________________________________________________________________________________________________________________________________________________________________________________________________________________________ The information contained in this message is privileged and intended only for the recipients named. If the reader is not a representative of the intended recipient, any review, dissemination or copying of this message or the information it contains is prohibited. If you have received this message in error, please immediately notify the sender, and delete the original message and attachments. From: dirk <[email protected] (mailto:[email protected])> To: Servers Alive Discussion List <[email protected] (mailto:[email protected])> Sent: 12/9/2015 10:55 AM Subject: RE: [SA-list] ErrorLevel AGAIN  How are you calling the bat file in Servers Alive? -------------------------------------------------------------------------------- From: Servers Alive Discussion List [mailto:[email protected] (mailto:[email protected])] On Behalf Of Jason Passow Sent: Wednesday, December 09, 2015 5:35 PM To: Servers Alive Discussion List Subject: Re: [SA-list] ErrorLevel AGAIN Mine returns in less than 3 seconds. I have changed the timeout to 30 with the same result. Jason Passow Network Administrator http://www.mwsco.com (http://www.mwsco.com) [email protected] (mailto:[email protected]) ph: (507) 494-5178 fax: (507) 454-8104 Mississippi Welder Supply Co., Inc. Please consider the environment before printing this email. ____________________________________________________________________________________________________________________________________________________________________________________________________________________________ The information contained in this message is privileged and intended only for the recipients named. If the reader is not a representative of the intended recipient, any review, dissemination or copying of this message or the information it contains is prohibited. If you have received this message in error, please immediately notify the sender, and delete the original message and attachments. From: Roderick Garcia <[email protected] (mailto:[email protected])> To: Servers Alive Discussion List <[email protected] (mailto:[email protected])> Sent: 12/9/2015 10:20 AM Subject: RE: [SA-list] ErrorLevel AGAIN I had a similar issue and mine turned out to be the timeout setting with was at the default 5. I wasn’t allocating enough time for the check to complete. Thus a false return. Roderick Garcia | Senior Systems Support Engineer American Cancer Society, Inc. 8400 Silver Crossing Oklahoma City, OK 73132 cancer.org (http://www.cancer.org) | 1.800.227.2345 (http://www.facebook.com/americancancersociety?societysignature=facebook) (http://www.twitter.com/americancancer?societysignature=twitter) (http://www.youtube.com/user/AmerCancerSociety?societysignature=youtube) (http://www.linkedin.com/company/american-cancer-society?societysignature=linkedin) (http://www.cancer.org/) (http://charityreports.bbb.org/public/seal.aspx?ID=1413312005) This message (including any attachments) is intended exclusively for the individual to whom it is addressed and may contain proprietary, protected, or confidential information. If you are not the named addressee, you are not authorized to read, print, copy, or disseminate this message or any part of it. If you have received this message in error, please notify the sender immediately. From: Servers Alive Discussion List [mailto:[email protected] (mailto:[email protected])] On Behalf Of Jason Passow Sent: Wednesday, December 09, 2015 9:50 AM To: Servers Alive Discussion List Subject: [SA-list] ErrorLevel AGAIN I have a check which always returns error level 0. It should not and from a command line it indeed does not. Using the Checkerrorlevel that comes with salive it does indeed show 0. Output .txt contains 2 for /F "delims=" %%a in (output.txt) do ( set "SHELL_EXIT_CODE=%%a" ) exit %SHELL_EXIT_CODE% Command line results: C:\Program Files (x86)\CountError\>CountError.bat C:\Program Files (x86)\CountError\>echo %errorlevel% 2 Jason Passow Network Administrator http://www.mwsco.com (http://www.mwsco.com) [email protected] (mailto:[email protected]) ph: (507) 494-5178 fax: (507) 454-8104 Mississippi Welder Supply Co., Inc. Please consider the environment before printing this email. ____________________________________________________________________________________________________________________________________________________________________________________________________________________________ The information contained in this message is privileged and intended only for the recipients named. If the reader is not a representative of the intended recipient, any review, dissemination or copying of this message or the information it contains is prohibited. If you have received this message in error, please immediately notify the sender, and delete the original message and attachments. To unsubscribe send a message with UNSUBSCRIBE in the subject line to [email protected] (mailto:[email protected]) If you use auto-responders (like out-of-the-office messages), make sure that they are not sent to the list nor to individual members. Doing so will cause you to be automatically removed from the list. To unsubscribe send a message with UNSUBSCRIBE in the subject line to [email protected] (mailto:[email protected]) If you use auto-responders (like out-of-the-office messages), make sure that they are not sent to the list nor to individual members. Doing so will cause you to be automatically removed from the list. To unsubscribe send a message with UNSUBSCRIBE in the subject line to [email protected] (mailto:[email protected]) If you use auto-responders (like out-of-the-office messages), make sure that they are not sent to the list nor to individual members. Doing so will cause you to be automatically removed from the list. No virus found in this message. Checked by AVG - www.avg.com (http://www.avg.com) Version: 2016.0.7294 / Virus Database: 4483/11146 - Release Date: 12/09/15 To unsubscribe send a message with UNSUBSCRIBE in the subject line to [email protected] (mailto:[email protected]) If you use auto-responders (like out-of-the-office messages), make sure that they are not sent to the list nor to individual members. Doing so will cause you to be automatically removed from the list. To unsubscribe send a message with UNSUBSCRIBE in the subject line to [email protected] (mailto:[email protected]) If you use auto-responders (like out-of-the-office messages), make sure that they are not sent to the list nor to individual members. Doing so will cause you to be automatically removed from the list. No virus found in this message. Checked by AVG - www.avg.com (http://www.avg.com) Version: 2016.0.7294 / Virus Database: 4483/11146 - Release Date: 12/09/15 To unsubscribe send a message with UNSUBSCRIBE in the subject line to [email protected] (mailto:[email protected]) If you use auto-responders (like out-of-the-office messages), make sure that they are not sent to the list nor to individual members. Doing so will cause you to be automatically removed from the list. To unsubscribe send a message with UNSUBSCRIBE in the subject line to [email protected] If you use auto-responders (like out-of-the-office messages), make sure that they are not sent to the list nor to individual members. Doing so will cause you to be automatically removed from the list.
