CheckFileDate (Full Version)

All Forums >> [Networking & Security] >> GFI Network Server Monitor



Message


edgein -> CheckFileDate (21.Jul.2004 4:42:00 AM)

Here is a little script which monitors the date of a file.

The function uses two arguments, strPath (path to the file) and intDaysOld (number of "days old" the file may be).

code:
Function CheckFileDate( strPath, intDaysOld )

On Error Resume Next

Dim objFSO, objFile

CheckFileDate = retvalUnknown ' Unless indicated otherwise

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPath)
If( Err.Number <> 0 ) Then
EXPLANATION = "Unable to retrieve filedate"
Else
If( objFile.DateLastModified > now-intDaysOld ) Then
EXPLANATION = "File date is OK; date=[" & objFile.DateLastModified & "], limit=[" & intDaysOld & " days]"
CheckFileDate = True
Else
EXPLANATION = "File date is exceeding the limit; date=[" & objFile.DateLastModified & "], limit=[" & intDaysOld & " days]"
CheckFileDate = False
End If
End If

End Function

Cheers /Bj÷rn




ecarlson -> RE: CheckFileDate (8.May2007 1:30:13 PM)

Thanks. I modified it a little to go by minutes instead of days, and to include the difference value in the Explanations. I use it with LANguard NSM to make sure that an application's log file is being updated regularly (the Modified date is not more than 30 minutes old). I can post the update if anyone is interested.




pjgfi -> RE: CheckFileDate (2.Jul.2009 4:35:00 AM)

Thanks for this script, it was exactly what I was looking for !




Page: [1]