Solved

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

Posted on 2009-07-01
3
577 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article will show, step by step, how to integrate R code into a R Sweave document
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

746 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now