External Rule
Hi,
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.
This discussion has been closed.
Comments
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.
Example:
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.
Regards,
Forum Administrator
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.
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
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'.
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.
cscript "C:Program FilesServersCheckexternalhello_b.vbs"
Not:
cscript "hello_b.vbs"