Verify that a File Exists

Posted: 5th March 2007 by Anders Bengtsson in Microsoft Operations Manager 2005, Scripts

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)
    Const EVENT_WARNING = 2
    Set objShell = CreateObject(“Wscript.Shell”)
    objShell.LogEvent 2, strFile & ” is not accessible.”
End If

  1. [...] monitor file exist Hi I have made you a simple script, you can find it here — Regards Anders Bengtsson [MCSE, MCSA] | anders AT | [...]