Solved

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

Posted on 2009-07-01
3
579 Views
Last Modified: 2013-12-26
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?
0
Comment
Question by:nlc_IT_Dept
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
kevin_u earned 500 total points
ID: 24760405
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

0
 

Author Comment

by:nlc_IT_Dept
ID: 24760471
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?
0
 

Author Comment

by:nlc_IT_Dept
ID: 24760506
Nevermind, working perfectly! Thanks kindly!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question