To Found Errors in log file
Sub foundErr
set fso = CreateObject("scripting.filesystemobject")
logfile = "Your logfile path here"
contents = fso.OpenTextFile( logfile ).readall
lines = split( contents, vbCRLF )
linecount = ubound(lines)
for i=0 to linecount
if instr(1, ucase( lines(i) ), "ERROR") then wscript.echo "error found in " & logfile & " at line " & i & ": " & lines(i)
next
End Sub
Function to Get Previous Log if current log is overwriten
Function Get_Previous_Log( path, filename )
set folder = fso.GetFolder(path)
Set files = folder.Files
for each file in files
if ucase( left(file.name, len(filename) ) ) = ucase( filename ) then
if ucase(file.name)<>ucase(filename & ".log") then if ucase(file.name) > ucase(prevfile) then prevfile = file.name
end if
next
if prevfile<>"" then Get_Previous_Log = prevfile
end Function
To get OS platform
'========================================================================' Sub Get LogPath and OS role' by Neven Radic' Set variables for temporary location of output and status files.' Output : strLogPath1 , OS Platform sOS: WORKSTATION | SERVER'========================================================================Sub GetLogPathOn Error Resume NextSet objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")Set colOSes = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")Dim sOS, strLogPath1For Each objOS in colOSes
If InStr(UCase(objOS.Caption),"XP") Then
strLogPath1="C:\XME\Utils" 'This is XP System
If ReportFolderStatus(strLogPath1) = "does not exist" Then
strLogPath1 = WshSysEnv("TEMP")
sOS = "WORKSTATION"
End If
ElseIf InStr(UCase(objOS.Caption),"7") Then ' This is Win 7
strLogPath1="C:\XOM\LOGS\SYSTEM"
If ReportFolderStatus(strLogPath1) = "does not exist" Then
strLogPath1 = WshSysEnv("TEMP")
sOS = "WORKSTATION"
End If
ElseIf InStr(UCase(objOS.Caption),"SERVER") then
strLogPath1="C:\NTUTILS"
If ReportFolderStatus(strLogPath1) = "does not exist" Then
strLogPath1 = WshSysEnv("TEMP")
sOS = "SERVER"
End If
Else
strLogPath1 = WshSysEnv("TEMP")
End If
Next
WScript.Echo "(strLogPath1):" & strLogPath1 & " - (sOS): " & sOS
End Sub
|