• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 593
  • Last Modified:

VB script to check the modified date on a specific file, and return a value

Hi all,

I'm using Solarwinds IP Monitor to ensure that a certain file is being copied each day onto a server. Unfortunately IP Monitor does not allow for this functionality out of the box, but it does allow you to run scripts that return an expected value, and set off an alert if this value is not returned.

SO..... I need a vb script to check the modified date on a specific file. if the modifeid date is a week older than the curren systemt date, return a value of 1. otherwise return 0

Can I get a hand from any scrpiting gurus?
  • 2
1 Solution
I believe this is what you wanted.

set fso = WScript.CreateObject("Scripting.FileSystemObject")
set f = fso.GetFile("somefile.txt")
if (Now - f.DateLastModified) > 7 then
	WScript.Quit 1
end if
WScript.Quit 0

Open in new window

nlc_IT_DeptAuthor Commented:
That looks very promising! Am I able to put a UNC path into the "set f = fso.GetFile("somefile.txt")" line or does it have to be a local path?
nlc_IT_DeptAuthor Commented:
Nevermind, working perfectly! Thanks kindly!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now