Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking on date

Status
Not open for further replies.

0318

Programmer
Jan 18, 2004
25
0
0
NL
sorry i post so much.. but theres almost nothing to find about my problem.
i need a script that looks in a map and checks the dates of all files in the map. when the files are in the map for more then 7 days the owner of the file must get a email about that.
i know its to much to ask.. and i looked the internet for hours and hours now..

hope someone can help, or just give me a example of such script..

thnx
 
you should find lots of posts on this forum about deleting files in a folder over a certain no. days old. you should also find lots of examples on how to send emails. combine these two and also loook for recursive folder and files searches. you will defo find all the info you need on this site if you search the faq for vbscript and use the keyword search
 
Well, i did search..
i have this:

for each File in Folderobj.files
if (Date - File.DateCreated > cint(MaxAgeOfFile)) then

its from a delete after ** days script.
how do i set MaxAgeOfFile ?
just above my script: Set MaxAgeOfFile = 7?
 
This line:
if (Date - File.DateCreated > cint(MaxAgeOfFile)) then
should be replaced with this:
if (Date - File.DateCreated) > cint(MaxAgeOfFile) then
And yes, the expression date2 - date1 returns the number of days between the two dates.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
0318,

Additionally, since you are checking file dates on *another* machine, I would verify that the remote machine's date is the same as the initiator's (assuming the initiator's date is correct). That being said, we would need a way of acquiring the remote machine's date info. One way would be thru WMI. There may be a simpler way, but, hey, I've been on a WMI kick lately! The code:

strComputer = "ComputerNameHere"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_LocalTime")
For Each objItem in colItems
Wscript.Echo "Day: " & objItem.Day
Wscript.Echo "Month: " & objItem.Month
Wscript.Echo "Year: " & objItem.Year
Next

Run the same loop for local and remote, compare the two and if a problem is there, it should be addressed before proceeding.

Hope this helps - BTW, this is an awesome site!
 
One note I found regarding this (though I have not tested it myself), I believe referencing this Win32_Local_Time object is only available for XP and 2003 Server.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top