








If you found any of the tools on this page helpful, any donations would be
appreciated.
|
Option Explicit
CONST ANALOG_ROOT_DIR = "E:\Analog"
CONST CONFIG_DIR = "configs"
CONST CONFIG_FILE = "Analog.cfg"
CONST OUTPUT_DIR = "E:\Analog\Reports"
CONST RM_ROOT_DIR = "E:\Analog"
CONST RM_SUBDIR = "RM"
CONST RM_INSTALLED = True
CONST RM_IMAGE_DIR = "../../images/"
CONST RDNS_ENABLED = True
CONST RDNS_EXE = "E:\Analog\rdnslogs.exe"
CONST RDNS_LOG_SWITCH = " -l "
CONST RDNS_CACHE_SWITCH = " -o "
CONST RDNS_CACHE_FILE = "dnscache"
CONST ADJUST_DATE_BY_GMT = True
CONST LOGFILE_ROOT_DIR = "E:\LogFiles\W3SVC1"
CONST PURGE_URLSCAN = true
CONST USE_NEW_FLOORS = TRUE
CONST strDailyFloor = "1r"
CONST strWeeklyFloor = "5r"
CONST strMonthlyFloor = "10r"
CONST strYearlyFloor = "25r"
Dim objFSO
Dim oShell
Dim strOutputDir
Dim strConfigDir
Dim strConfigFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = WScript.CreateObject ("WSCript.shell")
If Not IsCScript() Then
Wscript.echo "Analog_Run.VBS must be run with CScript."
Wscript.Quit 1
End if
IF Mid(OUTPUT_DIR,2,1) = ":" Then
strOutputDir = OUTPUT_DIR
Else
strOutputDir = objFSO.BuildPath(ANALOG_ROOT_DIR , OUTPUT_DIR)
End if
strConfigDir = objFSO.BuildPath(ANALOG_ROOT_DIR , CONFIG_DIR)
strConfigFile = objFSO.BuildPath(strConfigDir , CONFIG_FILE)
If Not objFSO.FolderExists(ANALOG_ROOT_DIR) Then
Wscript.echo "Analog Root Directory not found: " & ANALOG_ROOT_DIR
Wscript.Quit 1
End If
If RM_INSTALLED = True And Not objFSO.FolderExists(RM_ROOT_DIR) Then
Wscript.echo "Report Magic Root Directory not found: " & RM_ROOT_DIR
Wscript.Quit 1
End If
If RDNS_ENABLED = True And Not objFSO.FileExists(RDNS_EXE) Then
Wscript.echo "RDNS not found: " & RDNS_EXE
Wscript.Quit 1
End If
If Not objFSO.FolderExists(strConfigDir) Then
Output "Analog Config Directory not found: " & strConfigDir
Wscript.Quit 1
End if
If Not objFSO.FileExists(strConfigFile) Then
Output "Analog Config File not found: " & strConfigFile
Wscript.Quit 1
End if
If Not objFSO.FolderExists(strOutputDir) Then
objFSO.CreateFolder (strOutputDir)
If Not objFSO.FolderExists(strOutputDir) Then
Output "Analog_Run Output directory not found and could not be created: " & strOutputDir
Wscript.Quit 1
End if
End if
If Not objFSO.FolderExists(LOGFILE_ROOT_DIR) Then
Output "IIS Log Directory not found: " & LOGFILE_ROOT_DIR
Wscript.Quit 1
End if
Call Main()
Set objFSO = Nothing
Set oShell = Nothing
Sub Main()
Dim strFromDate
Dim strToDate
Dim dtDNSCheckDate
Dim iReportType
Dim strWeek
Dim strMonth
Dim strDay
Dim strTempDir
Dim strReportDir
Dim strCommand
Dim strRMFile
Dim strShortConfigFile
Output "------------------------------------------"
Output "Analog_Run.VBS at " & Now()
Output "------------------------------------------"
If Not ParseCommandLine(strFromDate, strToDate, iReportType) Then
If iReportType <> 0 Then
Output "Analog_Run.VBS - Invalid Command Line"
End if
wscript.echo "SYNTAX: Analog_Run.vbs "
wscript.echo " /H -> This message"
wscript.echo " <None> -> Daily Report for Today"
wscript.echo " /Day= -> Daily Report for Yesterday"
wscript.echo " /Day=MM/DD/YYYY -> Daily Report for date"
wscript.echo " /From=MM/DD/YYYY /To=MM/DD/YYYY -> Date Range Report"
wscript.echo " /Week= -> Weekly Report for Yesterday"
wscript.echo " /Week=MM/DD/YY -> Weekly Report for date"
wscript.echo " /Month= -> Monthly Report for Yesterday"
wscript.echo " /Month=MM/DD/YY -> Monthly Report for date"
wscript.echo " /Year= -> Yearly Report for Yesterday"
wscript.echo " /Year=MM/DD/YY -> Yearly Report for date"
Exit Sub
End if
If PURGE_URLSCAN Then
Output " ------------------------------------------"
Output " Purging URLScan lines..."
Call Purge(LOGFILE_ROOT_DIR)
Output " ------------------------------------------"
End if
Output " Running Analog From " & strFromDate & " to " & strToDate & "."
Select Case iReportType
Case 1
strReportDir = Year(strFromDate) & Get2DigitNumber(DatePart("m", strFromDate)) & Get2DigitNumber(DatePart("d", strFromDate))
If strFromDate <> strToDate Then
strReportDir = strReportDir & "-" & Year(strToDate) & Get2DigitNumber(DatePart("m", strToDate)) & Get2DigitNumber(DatePart("d", strToDate))
End If
Case 2
strReportDir = Year(strFromDate) & "_W" & Get2DigitNumber(DatePart("ww", strFromDate))
Case 3
strReportDir = Year(strFromDate) & Get2DigitNumber(DatePart("m", strFromDate))
Case 4
strReportDir = Year(strFromDate)
End Select
strTempDir = objFSO.BuildPath(strOutputDir, strReportDir)
If objFSO.FolderExists(strTempDir) Then
objFSO.DeleteFolder strTempDir, True
End if
On Error Resume Next
Output " Creating Output directory: " & strTempDir
objFSO.CreateFolder strTempDir
On Error Goto 0
If Not objFSO.FolderExists(strTempDir) Then
Output " *** Error Creating Output directory: " & strTempDir
End if
If CONFIG_DIR <> "" Then
strShortConfigFile = CONFIG_DIR & "\" & CONFIG_FILE
Else
strShortConfigFile = CONFIG_FILE
End if
If RDNS_ENABLED Then
Dim strRDNSLog
Select Case iReportType
Case 1
dtDNSCheckDate = CDate(strFromDate)
Do While (dtDNSCheckDate <= CDate(strToDate))
strRDNSLog = strRDNSLog & RDNS_LOG_SWITCH & CHR(34) & GetLogFileNameFromDate(dtDNSCheckDate) & CHR(34)
dtDNSCheckDate = dtDNSCheckDate + 1
Loop
Case 2
dtDNSCheckDate = CDate(strFromDate)
Do While (dtDNSCheckDate <= CDate(strToDate))
strRDNSLog = strRDNSLog & RDNS_LOG_SWITCH & CHR(34) & GetLogFileNameFromDate(dtDNSCheckDate) & CHR(34)
dtDNSCheckDate = dtDNSCheckDate + 1
Loop
Case 3
strRDNSLog = RDNS_LOG_SWITCH & CHR(34) & GetLogFileMonthFromDate(strFromDate) & CHR(34)
Case 4
strRDNSLog = RDNS_LOG_SWITCH & CHR(34) & GetLogFileYearFromDate(strFromDate) & CHR(34)
End Select
DnsCheckLogFile(strRDNSLog)
End If
strCommand = BuildAnalogCommandLine(strShortConfigFile, strFromDate, strToDate, strReportDir, iReportType, FALSE)
Output " Running: " & strCommand
On Error Resume Next
oShell.run strCommand, 0, True
On Error Goto 0
If RM_INSTALLED Then
On Error Resume Next
objFSO.CreateFolder objFSO.BuildPath(strTempDir, RM_SUBDIR)
IF objFSO.FileExists(objFSO.BuildPath(ANALOG_ROOT_DIR, "stylesheet.css")) Then
objFSO.CopyFile objFSO.BuildPath(ANALOG_ROOT_DIR, "stylesheet.css"), objFSO.BuildPath(objFSO.BuildPath(strTempDir, RM_SUBDIR), "stylesheet.css")
End if
On Error Goto 0
strCommand = BuildAnalogCommandLine(strShortConfigFile, strFromDate, strToDate, strReportDir, iReportType, TRUE)
Output " Running: " & strCommand
On Error Resume Next
oShell.run strCommand, 0, True
On Error Goto 0
strRMFile = Chr(34) & objFSO.BuildPath(objFSO.BuildPath(strOutputDir, strReportDir), "rmagic.rm") & Chr(34)
If WriteRMFile(objFSO.BuildPath(strOutputDir, strReportDir) ) Then
strCommand = Chr(34) & objFSO.BuildPath(RM_ROOT_DIR, "rmagic.exe") & Chr(34)
strCommand = strCommand & " " & strRMFile & " -statistics_File_In=" & OUTPUT_DIR & "\" & strReportDir & "\report.dat"
Output " Running: " & strCommand
On Error Resume Next
oShell.run strCommand, 0, True
On Error Goto 0
End if
End if
Output "------------------------------------------"
Output "END OF Analog_Run.VBS at " & Now()
Output "------------------------------------------"
End Sub
Function BuildAnalogCommandLine(strShortConfigFile, strFromDate, strToDate, strReportDir, iReportType, bReportMagic)
Dim strTemp
strTemp = Chr(34) & objFSO.BuildPath(ANALOG_ROOT_DIR, "analog.exe") & Chr(34)
strTemp = strTemp & " -G +g" & Chr(34) & strShortConfigFile & Chr(34)
strTemp = strTemp & " +C" & Chr(34) & "FROM " & DateFormatYYMMDD(strFromDate) & Chr(34)
strTemp = strTemp & " +C" & Chr(34) & "TO " & DateFormatYYMMDD(strToDate) & Chr(34)
strTemp = strTemp & " +C" & Chr(34) & "OUTFILE " & OUTPUT_DIR & "\" & strReportDir & "\Report."
If bReportMagic Then
strTemp = strTemp & "dat" & Chr(34) & " +C" & Chr(34) & "Output COMPUTER" & Chr(34)
Else
strTemp = strTemp & "html" & Chr(34)
End If
If RDNS_ENABLED Then
strTemp = strTemp & " +C" & Chr(34) & "DNS READ" & Chr(34)
End If
If ADJUST_DATE_BY_GMT Then
strTemp = strTemp & " +C" & Chr(34) & "LOGTIMEOFFSET " & GetGMTOffset(CDate(strFromDate)) & Chr(34)
End If
Select Case iReportType
Case 1
strTemp = strTemp & " +C" & Chr(34) & "MONTHLY OFF" & Chr(34) & " +C" & Chr(34) & "WEEKLY OFF" & Chr(34) & " +C" & Chr(34) & "DAILYREP OFF" & Chr(34) & " +C" & Chr(34) & "DAILYSUM OFF" & Chr(34)
Case 2
strTemp = strTemp & " +C" & Chr(34) & "DAILYSUM ON" & Chr(34) & " +C" & Chr(34) & "MONTHLY OFF" & Chr(34) & " +C" & Chr(34) & "WEEKLY OFF" & Chr(34)
Case 3
strTemp = strTemp & " +C" & Chr(34) & "WEEKLY ON" & Chr(34) & " +C" & Chr(34) & "MONTHLY OFF" & Chr(34)
Case 4
strTemp = strTemp & " +C" & Chr(34) & "WEEKLY ON" & Chr(34) & " +C" & Chr(34) & "MONTHLY ON" & Chr(34)
End Select
If USE_NEW_FLOORS Then
Select Case iReportType
Case 1
strTemp = strTemp & GetFloors(strDailyFloor)
Case 2
strTemp = strTemp & GetFloors(strWeeklyFloor)
Case 3
strTemp = strTemp & GetFloors(strMonthlyFloor)
Case 4
strTemp = strTemp & GetFloors(strYearlyFloor)
End Select
End if
BuildAnalogCommandLine = strTemp
End Function
Function GetFloors(floor)
Dim strTemp
strTemp = " +C" & Chr(34) & "REQFLOOR " & floor & Chr(34)
strTemp = strTemp & " +C" & Chr(34) & "ORGFLOOR " & floor & Chr(34)
strTemp = strTemp & " +C" & Chr(34) & "REFFLOOR " & floor & Chr(34)
strTemp = strTemp & " +C" & Chr(34) & "REFSITEFLOOR " & floor & Chr(34)
strTemp = strTemp & " +C" & Chr(34) & "HOSTFLOOR " & floor & Chr(34)
GetFloors = strTemp
End Function
Sub DnsCheckLogFile(strLogsToCheck)
Dim strCommand
strCommand = Chr(34) & RDNS_EXE & Chr(34)
strCommand = strCommand & " " & strLogsToCheck & RDNS_CACHE_SWITCH & RDNS_CACHE_FILE
Output " Running: " & strCommand
On Error Resume Next
oShell.run strCommand, 0, True
On Error GoTo 0
End Sub
Function GetLogFileNameFromDate(dtLogFileDate)
GetLogFileNameFromDate = objFSO.BuildPath(LOGFILE_ROOT_DIR, "ex" & Right(CStr(Year(dtLogFileDate)), 2) & Get2DigitNumber(DatePart("m", dtLogFileDate)) & Get2DigitNumber(DatePart("d", dtLogFileDate)) & ".log")
End Function
Function GetLogFileMonthFromDate(dtLogFileDate)
GetLogFileMonthFromDate = objFSO.BuildPath(LOGFILE_ROOT_DIR, "ex" & Right(CStr(Year(dtLogFileDate)), 2) & Get2DigitNumber(DatePart("m", dtLogFileDate)) & "*.log")
End Function
Function GetLogFileYearFromDate(dtLogFileDate)
GetLogFileYearFromDate = objFSO.BuildPath(LOGFILE_ROOT_DIR, "ex" & Right(CStr(Year(dtLogFileDate)), 2) & "*.log")
End Function
Function ParseCommandLine(ByRef strFromDate, ByRef strToDate, ByRef iReportType)
Dim strMonth
Dim strWeek
Dim strTemp
Dim strArg
Dim strValue
Dim iCount
Dim bFromFound
Dim bToFound
Dim bWeekFound
Dim bMonthFound
Dim bYearFound
ParseCommandLine = False
If Wscript.Arguments.count = 0 Then
strValue = Now
If Not ParseDateString(strValue) Then
ParseCommandLine = False
Exit Function
End if
strFromDate = strValue
strToDate = strValue
iReportType = 1
ParseCommandLine = True
Else
For iCount = 0 To Wscript.Arguments.count -1
Output "Command Line arg (" & iCount & "): " & Trim(Wscript.arguments.item(iCount))
strTemp = Trim(Wscript.arguments.item(iCount))
Select Case Ucase(strTemp)
Case "/?", "-?", "/H", "-H"
iReportType = 0
ParseCommandLine = False
Exit Function
End Select
If Instr(strTemp, "=") = 0 Then
ParseCommandLine = False
Exit Function
End if
strArg = UCASE(Left(strTemp, InStr(strTemp, "=") - 1))
strValue = Mid(strTemp, InStr(strTemp, "=") + 1)
Select Case strArg
Case "/FROM"
If Not ParseDateString(strValue) Then
ParseCommandLine = False
Exit Function
End if
strFromDate = strValue
bFromFound = True
Case "/TO"
If Not ParseDateString(strValue) Then
ParseCommandLine = False
Exit Function
End if
strToDate = strValue
bToFound = True
Case "/DAY"
If strValue = "" Then
strValue = DateAdd("d", -1, Date() )
End if
If Not ParseDateString(strValue) Then
ParseCommandLine = False
Exit Function
End if
strFromDate = strValue
strToDate = strValue
bFromFound = True
bToFound = True
Case "/WEEK"
If strValue = "" Then
strValue = DateAdd("d", -1, Date() )
End if
If Not ParseDateString(strValue) Then
ParseCommandLine = False
Exit Function
End if
strFromDate = strValue
strToDate = strValue
If Not FindFirstDayOfWeek(strFromDate) Then
ParseCommandLine = False
Exit Function
End if
if not FindLastDayOfWeek(strToDate) Then
ParseCommandLine = False
Exit Function
End if
bWeekFound = True
Case "/MONTH"
If strValue = "" Then
strValue = DateAdd("d", -1, Date() )
End if
If Not ParseDateString(strValue) Then
ParseCommandLine = False
Exit Function
End if
strFromDate = strValue
strToDate = strValue
If Not FindFirstDayOfMonth(strFromDate) Then
ParseCommandLine = False
Exit Function
End if
if not FindLastDayOfMonth(strToDate) Then
ParseCommandLine = False
Exit Function
End if
bMonthFound = True
Case "/YEAR"
If strValue = "" Then
strValue = DateAdd("d", -1, Date() )
End if
If Not ParseDateString(strValue) Then
ParseCommandLine = False
Exit Function
End if
strFromDate = strValue
strToDate = strValue
If Not FindFirstDayOfYear(strFromDate) Then
ParseCommandLine = False
Exit Function
End if
if not FindLastDayOfYear(strToDate) Then
ParseCommandLine = False
Exit Function
End if
bYearFound = True
Case Else
ParseCommandLine = False
Exit Function
End Select
Next
End If
If bYearFound And Not (bWeekFound OR bMonthFound OR (bFromFound And bToFound)) Then
iReportType = 4
ParseCommandLine = True
End if
If bMonthFound And Not (bWeekFound OR bYearFound OR (bFromFound And bToFound)) Then
iReportType = 3
ParseCommandLine = True
End if
If bWeekFound And Not (bMonthFound OR bYearFound OR (bFromFound And bToFound))Then
iReportType = 2
ParseCommandLine = True
End if
If (bFromFound And bToFound) AND NOT (bMonthFound OR bWeekFound OR bYearFound ) Then
iReportType = 1
ParseCommandLine = True
End if
End Function
Function FindFirstDayOfWeek(ByRef strDate)
If Not IsDate(strDate) Then
FindFirstDayOfWeek = False
Exit Function
End if
Do Until DatePart("w", strDate) = vbSUNDAY
strDate = DateAdd("d", -1, strDate)
Loop
FindFirstDayOfWeek = True
End Function
Function FindLastDayOfWeek(ByRef strDate)
If Not IsDate(strDate) Then
FindFirstDayOfWeek = False
Exit Function
End if
Do Until DatePart("w", strDate) = vbSATURDAY
strDate = DateAdd("d", 1, strDate)
Loop
FindLastDayOfWeek = True
End Function
Function FindFirstDayOfMonth(ByRef strDate)
If Not IsDate(strDate) Then
FindFirstDayOfMonth = False
Exit Function
End if
strDate = DateSerial(Year(strDate), Month(strDate), 1)
FindFirstDayOfMonth = True
End Function
Function FindLastDayOfMonth(ByRef strDate)
If Not IsDate(strDate) Then
FindLastDayOfMonth = False
Exit Function
End if
strDate = DateSerial(Year(strDate), Month(strDate) + 1, 0)
FindLastDayOfMonth = True
End Function
Function FindFirstDayOfYear(ByRef strDate)
If Not IsDate(strDate) Then
FindFirstDayOfYear = False
Exit Function
End if
strDate = DateSerial(Year(strDate), 1, 1)
FindFirstDayOfYear = True
End Function
Function FindLastDayOfYear(ByRef strDate)
If Not IsDate(strDate) Then
FindLastDayOfYear = False
Exit Function
End if
strDate = DateSerial(Year(strDate), 12, 31)
FindLastDayOfYear = True
End Function
Function Get2DigitNumber(fromNumber)
Get2DigitNumber = fromNumber
If fromNumber < 10 Then
Get2DigitNumber = "0" & Get2DigitNumber
End if
End Function
Function ParseDateString(ByRef strString)
Dim strMonth
Dim strDay
Dim strYear
If Not IsDate(strString) Then
ParseDateString = False
Exit Function
Else
strMonth = Month(strString)
If cInt(strMonth) < 10 Then
strMonth = "0" & strMonth
End if
strDay = Day(strString)
If cInt(strDay) < 10 Then
strDay = "0" & strDay
End if
strYear = Year(strString)
strString = DateSerial (strYear, strMonth, strDay)
ParseDateString = True
End if
End Function
Function DateFormatYYMMDD(strDate)
Dim strMonth
Dim strDay
Dim strYear
strMonth = Month(strDate)
If cInt(strMonth) < 10 Then
strMonth = "0" & strMonth
End if
strDay = Day(strDate)
If cInt(strDay) < 10 Then
strDay = "0" & strDay
End if
strYear = MID(Year(strDate),3,2)
DateFormatYYMMDD = strYear & strMonth & strDay
End Function
Function GetGMTOffset(testDate)
Dim HexVal
GetGMTOffset = oShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\Bias")
If IsDSTDate(testDate) Then
GetGMTOffset = GetGMTOffset + oShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\DaylightBias")
End If
If IsArray(GetGMTOffset) Then
HexVal = Hex(GetGMTOffset(3)) & Hex(GetGMTOffset(2)) & Hex(GetGMTOffset(1)) & Hex(GetGMTOffset(0))
Else
HexVal = Hex(GetGMTOffset)
End If
GetGMTOffset = - CLng("&H" & HexVal)
End Function
Function IsDSTDate(testDate)
If ((testDate >= GetDSTStartDate(Year(testDate))) And (testDate < GetDSTEndDate(Year(testDate)))) Then
IsDSTDate = True
Else
IsDSTDate = False
End If
End Function
Function GetDSTStartDate(testYear)
GetDSTStartDate = DateSerial(testYear, 4, 1)
Do Until Weekday(GetDSTStartDate) = vbSunday
GetDSTStartDate = GetDSTStartDate + 1
Loop
End Function
Function GetDSTEndDate(testYear)
GetDSTEndDate = DateSerial(testYear, 10, 31)
Do Until Weekday(GetDSTEndDate) = vbSunday
GetDSTEndDate = GetDSTEndDate - 1
Loop
End Function
Function WriteRMFile(strReportDir)
Dim objTS
Dim strOutDir
Set objTS = objFSO.OpenTextFile(objFSO.BuildPath(strReportDir, "rmagic.rm"), 8, true)
strOutDir = objFSO.BuildPath(strReportDir, RM_SUBDIR)
objTS.Writeline "[statistics]"
objTS.Writeline "File_In = " & Replace(objFSO.BuildPath(strReportDir, "report.dat"), "\", "/")
objTS.Writeline "Frame_File_Out = " & Replace(strOutDir & "/index.html", "\", "/")
objTS.Writeline "Reverse_Time = 1"
objTS.Writeline "Language = en"
objTS.Writeline "Format= XHTML 1.0"
objTS.Writeline "[reports]"
objTS.Writeline "Active_Column=R"
objTS.Writeline "File_Out = " & Replace(strOutDir & "/", "\", "/")
objTS.Writeline "Stylesheet=stylesheet.css"
objTS.Writeline "Image_Dir = " & RM_IMAGE_DIR
objTS.Writeline "[QUICK]"
objTS.Writeline "Rows = ALL"
objTS.Writeline "[graphs]"
objTS.Writeline "BG_Color = #FFFFCC"
objTS.Writeline "[navigation]"
objTS.Writeline "File_Out = nav.html"
objTS.Writeline "Stylesheet=stylesheet.css"
objTS.Writeline "[website]"
objTS.Writeline "Base_URL = ${HU}"
objTS.Close
Set objTS = Nothing
WriteRMFile = TRUE
End Function
Sub Purge(strLogDir)
Dim objDir
Dim colFiles
Dim objFile
Dim objRegExp
Dim objOutFile
Dim bProcess
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
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 objFile = Nothing
Set objRegExp = Nothing
Set colFiles = Nothing
Set objDir = Nothing
End If
End Sub
Sub RemoveURLScan(strInFile, strOutFile)
Dim objTS
Dim objTSOut
Dim strLine
Dim objRegExp
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
Set objRegExp = Nothing
Set objTS = Nothing
Set objTSOut = Nothing
End Sub
Function IsCScript()
IsCscript = False
On Error Resume Next
Select Case Ucase(StrReverse(Left(StrReverse(WScript.FullName), Instr(StrReverse(WScript.FullName),"\") - 1)))
Case "CSCRIPT.EXE"
IsCscript = True
Case Else
IsCscript = False
End Select
On Error Goto 0
End Function
Sub Output(strString)
Dim strLogFile
Dim objTS
strLogFile = objFSO.BuildPath(ANALOG_ROOT_DIR, "Analog_Run.log")
Set objTS = objFSO.OpenTextFile(strLogFile, 8, true)
Wscript.Echo strString
objTS.Writeline strString
objTS.Close
Set objTS = Nothing
End Sub
|