VBScript to check if file has been modifed - send email if not

Please can someone provide or help me with a vbscript that can check if a specified file has been modified.
If the file hasn't been modified in the last hour then an email must be sent.

I plan only using the windows scheduler to run the script, this will check if a report has been updated and if it hasn't it will email me to tell me it hasn't been updated and therefore requires my attention

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You just need to download blat.exe and change the path in this script to point to it.

(tested and working from my machine; with appropriate mail setting changes and blat path file set correctly)

'set this variable to the path of your file
strFilePath = "C:\temp\oraclerecovery.log"

Set objFSO = CreateObject("Scripting.FileSystemObject")
set objFile = objFSO.GetFile(strFilePath)
Set objShell = WScript.CreateObject("WScript.Shell")

DateLastMod = CDate( objFile.DateLastModified)
if DateDiff("h",DateLastMod,Now)>0 then
   'dates differ, file is 1 hour old or older

    'set mail settings appropriately
	strMailSubject="The File " & strFilePath & " has changed in the last hour"
	strMailBody="The monitored file has changed in the last hour"
	'uncomment this for debugging
	'WScript.Echo "c:\utils\blat.exe -body " & chr(34) & strMailBody & chr(34) & " -f " & chr(34) & strMailFrom & chr(34) & " -server " & chr(34) & strMailServer & chr(34) & " -subject " & chr(34) & strMailSubject & chr(34) & " -to " & chr(34) & strMailTo & chr(34)
	'be sure to change path to blat.exe for this to work
    strErrorCode = objShell.Run ("c:\utils\blat.exe -body " & chr(34) & strMailBody & chr(34) & " -f " & chr(34) & strMailFrom & chr(34) & " -server " & chr(34) & strMailServer & chr(34) & " -subject " & chr(34) & strMailSubject & chr(34) & " -to " & chr(34) & strMailTo & chr(34),0,True)
	'remove this error echo if you don't want
	WScript.Echo strErrorCode
end if

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Another option would be to move or delete the report, and then just check for its existence--assuming the name would always be the same.  To do that, just change the
if DateDiff("h",DateLastMod,Now)>0 then

Open in new window

line to be
If not (fso.FileExists(strFilePath)) Then

Open in new window

antoniokingAuthor Commented:
Thanks, great solution!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.