Check if Minidumps are older then 2 weeks

Visual Basic Script Engine Runtime
Admin
Site Admin
Posts: 951
Joined: Thu Aug 23, 2007 10:35 am

Check if Minidumps are older then 2 weeks

Postby Admin » Fri Jun 03, 2011 5:46 pm

Code: Select all

Option Explicit
Dim FSO,File,folder,files,folderIdx,LogFile
Dim Date1,Date2,Hour1,Hour2
set FSO=CreateObject("Scripting.FileSystemObject")
Date1=Now()
wscript.echo "Today is " & Date1
Hour1=DatePart("h",Date1) 

'wscript.echo DateDiff("d",Date2,Date1),"Days"
'wscript.echo DateDiff("h",Date2,Date1),"Hours"
'wscript.echo DateDiff("n",Date2,Date1),"Minutes"
'wscript.echo DateDiff("s",Date2,Date1),"Seconds"

Set LogFile = FSO.OpenTextFile("C:\windows\Minidump\Log.txt", 8, True)

Set folder = FSO.GetFolder("C:\windows\Minidump") 
LogFile.WriteLine "Today is " & Date1
Set files = folder.Files
For each folderIdx In files   
   wscript.echo(folderIdx.Name & " " & folderIdx.DateLastModified & " - " & DateDiff("d",folderIdx.DateLastModified,Now()) & " Days Old")    
   if DateDiff("d",folderIdx.DateLastModified,Now()) > 14 and folderIdx.Name <> "Log.txt" then
      LogFile.WriteLine folderIdx.Name & " " & folderIdx.DateLastModified & " - " & DateDiff("d",folderIdx.DateLastModified,Now()) & " Days Old"
   end if
Next
LogFile.WriteLine
LogFile.WriteLine "--------------------------------"
LogFile.WriteLine
LogFile.Close
SET LogFile = NOTHING

Return to “VBS”

Who is online

Users browsing this forum: No registered users and 1 guest