I'm completely new to programming and scripting. I need a script that searches a folder for a file named *_single.xml and a file named *_full.xml. It must find at least one of each that has been modified within the last five minutes. If either one of these files does not exist with a last modified date of within five minutes, the script will fire a windows event. The script I have right now checks a specific file to see if it has been checked within five minutes, but now I need the script to search the folder for those two files and check the date modified on all results. Here's my current script. Thanks in advance for any help!
----------------------------------------------------------------------------------------------------------
Option Explicit

'* DEFINE CONSTANTS
Const EVENT_ERROR = 1
Const EVENT_INFORMATIONAL = 4

'* DECLARE VARIABLES

Dim objShell, objExecObject, strText
Dim FSO,File
Dim Date1,Date2,Hour1,Hour2

'* Set environment and open output file

Set objShell = WScript.CreateObject("WScript.Shell")
set FSO=CreateObject("Scripting.FileSystemObject")
Set File=FSO.GetFile("c:\test\test.txt")

Date1=Now()
Date2=File.DateLastModified
'wscript.echo DateDiff("s",Date2,Date1),"Seconds"

If DateDiff("s",Date2,Date1) > 300 then
objShell.LogEvent EVENT_ERROR, "file has not been written to within the last 5 minutes"
End if
[font="times new roman"]
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
Not a bad start! :)

There must be a quadzillion sample files on the web for searching a folder for files which could easily be adapted. Try http://www.computerperformance.co.uk as a kick-off.

Remember 1) that indentation makes your code easier to read and 2) to use the CODE tag for code (and other lengthy text):If DateDiff("s",Date2,Date1) > 300 then
objShell.LogEvent EVENT_ERROR, "file has not been written to within the last 5 minutes"
End If
You access the tag by clicking the button marked '<%' in the 'Message' window or, much quicker, by typing a left square bracket, the word 'code', then a right square bracket. Close the tag by prefixing the word 'code' with a forward slash, '/'.
Answered 08/06/2009 by: VBScab
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity