'************************************************************************************ '* Name: Check for File Existence '* '* Company: Alta Resources '* '* Author: Justin Harter '* '* Description: Checks to see if a specified file exists '* '* Parameters: FileName '************************************************************************************ 'Set Constants Const FILENAME_PARAM_NAME = "FileName" Const EVENT_TYPE_SUCCESS = 0 Const EVENT_TYPE_ERROR = 1 Const EVENT_TYPE_WARNING = 2 Const EVENT_TYPE_INFO = 4 Const EVENTLOG_AUDIT_SUCCESS = 8 Const EVENTLOG_AUDIT_FAILURE = 16 'Declare Variables Dim FileToMonitor 'Get the Parameter FileToMonitor = ScriptContext.Parameters.Get(FILENAME_PARAM_NAME) If FileExists(FileToMonitor) Then CreateEvent() End if Function FileExists(strFile) 'Declare Variables Dim FSO Dim FilePath 'Create File System Object set FSO = CreateObject("Scripting.FileSystemObject") FilePath = FSO.GetAbsolutePathName(strFile) 'Check for File Existence If FSO.FileExists(FilePath) then FileExists = True Else FileExists = False End if End Function sub CreateEvent() Dim oEvent 'Create a New Event Set oEvent = ScriptContext.CreateEvent 'Set Event Properties With oEvent .Message = "The file " & FileToMonitor & " currently exists." .EventNumber = 15000 .EventType = EVENT_TYPE_INFO End With 'Submit the Event to MOM ScriptContext.Submit oEvent Set oNewEvent = Nothing End sub