VB Script to monitor date/time modified folder

Hi experts,

I must create a script to monitor a folder if it has not been modified because the files that are alocated on that folder stay there only a few seconds, so I thing the best way is to monitor not the files but the last modified date of the folder that contains those files. I plan to run the script remotely.

The script should show a message like this: Wscript.Echo "Message: last date/time modified", and an output error like this: Wscript.Quit(4), if the last date modified is less than 30 minutes of the current date/time.

Thanks in advance for your help
andresskAsked:
Who is Participating?

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

x
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.

prashanthdCommented:
Hi,

Try the following code.

regards
Prashanth

Folder_Path = "\\servername\drivename$\foldername" 'Example \\DCSERVER01\c$\monitor

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFolder = objFSO.GetFolder(Folder_Path)

WScript.Echo "Message:" & objfolder.DateLastModified

If DateDiff("n",objfolder.DateLastModified,Now)< 30 Then
      WScript.Echo "Modified time < 30 Mins"
      WScript.Quit(4)
End If
0

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
andresskAuthor Commented:
It worked perfectly.
Thanks
0
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.