Home » Microsoft Operations Manager 2005 » Verify that a File Exists

Verify that a File Exists

This is a simple script that will check if a file exists, if not it will generate a warning event in the local event viewer. You can pick up that event with a rule from MOM. In this example, the script verify if C:\pagefile.sys exists.

Set objFSO = CreateObject(“Scripting.FileSystemObject”)

strFile = “C:\pagefile.sys”

If objFSO.FileExists(strFile) Then
    Set objFolder = objFSO.GetFile(strFile)
Else
    Const EVENT_WARNING = 2
    Set objShell = CreateObject(“Wscript.Shell”)
    objShell.LogEvent 2, strFile & ” is not accessible.”
End If


1 Comment

Comments are closed.