Solved

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TT Auto Dashboard 13 95
RUNRMTCMD from AS/400 12 69
Quickest way to query Windows Event ID from a Linux Device 3 51
AWK Code gives empty file, why? 12 36
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article will show, step by step, how to integrate R code into a R Sweave document
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

860 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