' ********************************************************************* ' ' Name : Print.vbs ' Author : 3Ds (UK) Limited ' Description : Example VBScript to send Sentry-go alert information ' to a printer. ' ' Arguments : None. ' ' WIZARD:PARAMS=This script requires no parameters ' WIZARD:PARAMEXAMPLE= ' ' Returns : 0 - Success ' 1 - An error occurred. ' ' WIZARD:RESULTS=Return code ...||0 = OK|1 = An error prevented the script from running.||Script output also indicates "OK" for success, or "Error" with details of the faults found. ' ' Notes : Requires Windows Scripting Host (for VBScript). Should ' be called from Sentry-go as an Alert Engine file in ' order to expand the error-specific place-markers. ' ' Change the "TODOs" for your own requirements. ' ' ********************************************************************* ' Enable in-line error handling On Error Resume Next ' ------ Local declarations ------ Dim objFSO ' File System Object Dim objPrinter ' Printer object Dim strPrinterPort ' Port to print to Dim strTextToPrint ' Error string to send to the printer ' ------ Main Logic ------ ' TODO: Set the following value to the appropriate port - normally LPT1: strPrinterPort = "LPT1:" ' Build our error using Sentry-go's place-markers strTextToPrint = "Sentry-go Monitored Error Detected!" & vbCrLf & vbCrLf & "Sentry-go monitored error logged on <$$TIMELOGGED>. Error: <$$ERROR> on Server: <$$SERVER>" & vbCrLf & vbCrLf ' Access the networking object - this gives us access to the printer Set objFSO = CreateObject("Scripting.FileSystemObject") If Err.Number <> 0 Then ' Error WScript.Echo "Error. Unable to create the file system object. " & Err.Description WScript.Quit(1) End If ' Print to the new connection Set objPrinter = objFSO.CreateTextFile(strPrinterPort, True) If Err.Number <> 0 Then ' Error Set objFSO = Nothing WScript.Echo "Error. Unable to link to printer port " & strPrinterPort & ". " & Err.Description WScript.Quit(1) End If objPrinter.Write(strTextToPrint) If Err.Number <> 0 Then ' Error Set objFSO = Nothing WScript.Echo "Error. Unable to send document to the printer. " & Err.Description WScript.Quit(1) End If ' Close it objPrinter.Close ' ------ Cleanup ------ Set objPrinter = Nothing Set objFSO = Nothing WScript.Echo "OK. Document was printed successfully" WScript.Quit(0) ' ------ End of Script ------