'****************************************************************************** '* '* Checks Schedule Tasks for Startup Errors and Write Error in Eventlog '* Dateiname CheckSched.vbs '* '****************************************************************************** '* '* Version 00.00.01 / Mo 11.08.2004 / Michael Müller '* '****************************************************************************** '* '* Revision '* Version 00.00.01 / Mo 11.08.2004 / Michael Müller '* '****************************************************************************** '* '* Description: '* The Script generates a log file with the command schtasks. This log file will be read and if a job '* failes an Eventlog entry is created. The Problem on Eventlog creation with WSH is, that all Eventlogs '* are created with ID 1, so you have to create a rule in MOM which filters '* for Description. "Schedule Job:" '* '****************************************************************************** Option Explicit DIM CSV3, objFSO, objTextFile, strNextLine, arrServiceList, String3, i DIM objshell, sCommand, systempath Const ForReading = 1 Const EVENT_ERROR = 1 Set objShell = Wscript.Createobject("WScript.Shell") SystemPath = objShell.ExpandEnvironmentStrings("%SYSTEMROOT%") sCommand = "cmd /C schtasks.exe /query /FO CSV /NH >%SystemRoot%\output.txt" objShell.run sCommand Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFSO.OpenTextFile _ (SystemPath &"\output.txt", ForReading) Do until objTextFile.AtEndOfStream strNextLine = objTextFile.Readline arrServiceList = Split(strNextLine , ",") For i = 2 to Ubound(arrservicelist) if arrServicelist(i) = """Could not start""" then 'wscript.echo "MATCH" objshell.logevent EVENT_ERROR, _ "Schedule Job: " & arrServicelist(0) & " Could not start. Please check Logon Account or Password." 'else 'wscript.echo "FAULT" End If next Loop