'----------------------------------------+---------------------------------------- ' RemoveURLScan_All - Processes all IIS logfiles (exYYMMDD.log) to remove ' URLScan lines and saves as Purged_exYYMMDD.log ' ' Copyright© 2002, Christopher G. Lewis - HTTP://www.ChristopherLewis.com ' ' NOTE - this processes all the files in the directory, so log files that have ' already been processed get reprocessed. Should probably check the date on ' the exYYMMDD.log vs any Purged_exYYMMDD.log before calling RemoveURLScan. ' ' Date Name Comment ' ------ ------- ----------------------------------------------------------------- ' 011227 CGL Created '----------------------------------------+---------------------------------------- DIM strLogDir strLogDir = "E:\LogFiles\W3SVC1" Call Main() Sub Main() Dim objFSO Dim objDir Dim colFiles Dim objFile Dim objOutFile Dim objRegExp Dim bProcess Set objFSO = CreateObject("Scripting.FileSystemObject") If objFSO.FolderExists(strLogDir) Then Set objDir = objFSO.GetFolder(strLogDir) Set colFiles = objDir.Files Set objRegExp = New RegExp objRegExp.Pattern = "^ex\d\d\d\d\d\d.log" objRegExp.IgnoreCase = True For Each objFile in colFiles If objRegExp.Test (objFile.Name) Then bProcess = False ' Check for Purged file If objFSO.FileExists (objFSO.BuildPath(objFile.ParentFolder, "Purged_" & objFile.Name) ) Then Set objOutFile = objFSO.GetFile( objFSO.BuildPath(objFile.ParentFolder, "Purged_" & objFile.Name) ) If DateDiff("s", objFile.DateLastModified, objOutFile.DateLastModified ) < 0 Then bProcess = true End if Else bProcess = True End if If bProcess Then Call RemoveURLScan(objFSO.BuildPath(objFile.ParentFolder, objFile.Name), objFSO.BuildPath(objFile.ParentFolder, "Purged_" & objFile.Name)) End if End If Next Set objOutFile = Nothing Set objFile = Nothing Set objRegExp = Nothing Set colFiles = Nothing Set objDir = Nothing End If Set objFSO = Nothing End Sub '------------------------------+------------------------------ ' RemoveURLScan.vbs ' ' Date name Comment ' ------ ------- ---------------------------------------------- ' 011227 CGL Created '------------------------------+------------------------------ Sub RemoveURLScan(strInFile, strOutFile) Dim objFSO Dim objTS Dim objTSOut Dim strLine Dim objRegExp Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTS = objFSO.OpenTextFile(strInFile , 1, False) Set objTSOut = objFSO.CreateTextFile(strOutFile, True) Set objRegExp = New RegExp objRegExp.Pattern = "Rejected-By-UrlScan" objRegExp.IgnoreCase = True Do While Not objTS.atEndOfStream strLine = objTS.ReadLine If Not objRegExp.Test(strLine) Then objTSOut.WriteLine strLine End if Loop objTS.Close objTSOut.Close 'Clean up Set objRegExp = Nothing Set objTS = Nothing Set objTSOut = Nothing Set objFSO = Nothing End Sub '------------------------------+------------------------------ 'End of RemoveURLScan_All.vbs '------------------------------+------------------------------