VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Get the application event log items using Win32_NTLogEvent WMI class

by Karthikeyan (187 Submissions)
Category: Miscellaneous
Compatability: VB Script
Difficulty: Unknown Difficulty
Originally Published: Tue 11th May 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Get the application event log items using Win32_NTLogEvent WMI class

Rate Get the application event log items using Win32_NTLogEvent WMI class



On Error Resume Next
Computer = "."
Set WMIService = GetObject("winmgmts:\\" & Computer & "\root\cimv2")
Set Items = WMIService.ExecQuery("Select * from Win32_NTLogEvent where Logfile='Application'")
Set OutFile = CreateObject("WScript.Shell")
Const ForAppending = 2
Set FileSystem = CreateObject("Scripting.FileSystemObject")
Set TextFile = FileSystem.OpenTextFile ("c:\AppEventLog.txt", ForAppending, True)
TextFile.WriteLine "Application Event Log Details as follows......"
TextFile.WriteLine
For Each EventLog in Items
TextFile.WriteLine "**********************************************************************"
TextFile.WriteLine "Category: " & EventLog.Category
TextFile.WriteLine "CategoryString: " & EventLog.CategoryString
TextFile.WriteLine "ComputerName: " & EventLog.ComputerName
TextFile.WriteLine "Data: " & EventLog.Data
TextFile.WriteLine "Event Code: " & EventLog.EventCode
TextFile.WriteLine "Event Identifier: " & EventLog.EventIdentifier
TextFile.WriteLine "Event Type: " & EventLog.EventType
TextFile.WriteLine "Insertion Strings: " & EventLog.InsertionStrings
TextFile.WriteLine "Logfile: " & EventLog.Logfile
TextFile.WriteLine "Message: " & EventLog.Message
TextFile.WriteLine "Record Number: " & EventLog.RecordNumber
TextFile.WriteLine "Source Name: " & EventLog.SourceName
TextFile.WriteLine "Time Generated: " & EventLog.TimeGenerated
TextFile.WriteLine "Time Written: " & EventLog.TimeWritten
TextFile.WriteLine "Type: " & EventLog.Type
TextFile.WriteLine "User: " & EventLog.User
TextFile.WriteLine "**********************************************************************"
Next
TextFile.Close
OutFile.Run "notepad.exe c:\AppEventLog.txt",1,True


Download this snippet    Add to My Saved Code

Get the application event log items using Win32_NTLogEvent WMI class Comments

No comments have been posted about Get the application event log items using Win32_NTLogEvent WMI class. Why not be the first to post a comment about Get the application event log items using Win32_NTLogEvent WMI class.

Post your comment

Subject:
Message:
0/1000 characters