File Availability older than: create or modification date

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
AndreT78
Posts: 15
Joined: Wed Feb 05, 2020 5:28 am

File Availability older than: create or modification date

Post by AndreT78 »

Hi,

File Availibility test: create or modification date

where can i choose which date would be tested ?

Thanks
BR Andre
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

This test does not check creation time, just last modification time (modification time = creation time when file was not edited).

If you need to check creation time, you may use Shell Script test and some simple script like this:

Code: Select all

Option Explicit
const statusUnknown     = "scriptRes:Unknown:"
const statusOk          = "scriptRes:Ok:"
const statusBad         = "scriptRes:Bad:"

Dim fso, objFSO, objFile, strFile, objArgs, diff
Set objArgs = WScript.Arguments

if objArgs.Count<1 then
  WScript.StdOut.Write statusUnknown & "required parameters: <path to file> [<threshold in hours>]"
  Wscript.Quit
End if

strFile = objArgs(0)
Set objFSO = CREATEOBJECT("Scripting.FileSystemObject")
if objFSO.FileExists(strFile) then
  SET objFile = objFSO.GetFile(strFile)
else
  WScript.StdOut.Write statusUnknown & "File does not exists: " & strFile
  Wscript.Quit
end If

if objArgs.Count=1 then
  WScript.StdOut.Write statusOk & objFile.DateCreated
else
  diff = DateDiff("h", objFile.DateCreated, Now())
  if diff > int(objArgs(1)) then
    WScript.StdOut.Write statusBad & diff
  else
    WScript.StdOut.Write statusOk & diff
  end if
end if
Regards
Alex
Post Reply