External Rule



I'm evaluating the external rule possibilities and I've found that the rule will run a vbs file along with bat files, however I can't manage to pass back any completion value to ServersCheck with either script.

Please could someone post an example vbscript or .BAT file (preferably both) which passes back the errorstatus code on completion? If I can find a way to do this with vbscript then buying this becomes a must! Cheers, Tom.


  • AdministratorAdministrator
    Here is a sample that should help you solve the issue.

    When you have a vbscript it usually writes the output to a popup window. By using the cscript command, it outputs to the console (which is required for the external check). However you can't run cscript directly.

    The workaround is to create a batch file in the "external" subdirectory that will do the cscript call.


    1/ hello.vbs


    Wscript.Echo "hello"

    2/ hello.bat

    rem =======

    cscript hello.vbs

    In your check the content to verify would be hello

    This should solve it.


    Forum Administrator
  • tom_clarktom_clark

    Thanks for the reply, unfortunately though I tried to get this working exactly as you've written it but am having trouble getting any return value.

    When setting up the rule, I've clicked 'Test Settings' and the pop-up box never displays a 'Value Returned'. I have ensured that the script is running by placing a msgbox in temporarily (which opens when the check runs), but cannot for the life of me get a value to be returned to the interface.

  • AdministratorAdministrator
    The script may not (!) return a message box as this will not be visible.

    Your script should write to the console (cscript) and you should verify for the content returned.

    Try to run the above example. Make sure that both the hello.vbs and the hello.bat are located in the "external" subdirectory of ServersCheck
  • tom_clarktom_clark

    Sorry, crossed wires!

    I only put in a msgbox to confirm that ServersCheck was executing the script through the batch file (which it was), but normally the script only contained wscript.echo and batch file used cscript.

    It's the verification of the content that I cannot get to work as ServersCheck reports that nothing was returned when I click on 'Test Rule'.

  • AdministratorAdministrator
    Can you copy in here what you entered in the configuration and what the output is of the "test rule"?
  • tom_clarktom_clark

    I've just done some more testing as I assumed I was doing something wrong and found out a couple of interesting points:

    When you click 'Test Settings' on Step 4, the pop-up box never shows a returned value (which was why I was thinking the rule wasn't working), however the value IS returned from the script because putting in an incorrect value makes the check fail.

    The other reason I thought it wasn't working was because of the way I was making the script fail. If you look for the word "hello" and the script returns "asdhello", then the check will still show success as the word "hello" is contained within the string - i.e. the check is doing an IF EXISTS, not a literal comparison.

    If you leave the expected value blank then the check will always return true as a zero length string will always be returned no matter what - e.g. if you leave the expected field blank and the script returns "fail" then the rule will return success. Kind of obvious when you think about it.

  • tom_clarktom_clark
    Not sure if any of this is useful to anyone, but I've also found that it's best to put the full path to the vbscript in the batch file, e.g.

    cscript "C:Program FilesServersCheckexternalhello_b.vbs"


    cscript "hello_b.vbs"
This discussion has been closed.