VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Get the Events of all Log File using Win32_NTLogEvent WMI Class

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

Get the Events of all Log File using Win32_NTLogEvent WMI Class

Rate Get the Events of all Log File using Win32_NTLogEvent WMI Class



'Generated using 'WMI Win32 Class Autoscript Generator' - Developed by Karthikeyan
'Homepage: http://www.geocities.com/marskarthik

On Error Resume Next
Computer = "."
Set OutFile = CreateObject("WScript.Shell")
Const ForAppending = 2
Set FileSystem = CreateObject("Scripting.FileSystemObject")
Set TextFile = FileSystem.OpenTextFile ("c:\Win32_NTLogEvent.txt", ForAppending, True)
TextFile.WriteLine "Script for Win32_NTLogEvent Class by Karthikeyan"
TextFile.WriteLine 
Set WMIService = GetObject("winmgmts:\\" & Computer & "\root\cimv2")
Set Items = WMIService.ExecQuery("Select * from Win32_NTLogEvent",,48)
For Each SubItems in Items
TextFile.WriteLine "********************************************************************"
    TextFile.WriteLine "Category: " & SubItems.Category
    TextFile.WriteLine "CategoryString: " & SubItems.CategoryString
    TextFile.WriteLine "ComputerName: " & SubItems.ComputerName
    TextFile.WriteLine "Data: " & SubItems.Data
    TextFile.WriteLine "EventCode: " & SubItems.EventCode
    TextFile.WriteLine "EventIdentifier: " & SubItems.EventIdentifier
    TextFile.WriteLine "EventType: " & SubItems.EventType
    TextFile.WriteLine "InsertionStrings: " & SubItems.InsertionStrings
    TextFile.WriteLine "Logfile: " & SubItems.Logfile
    TextFile.WriteLine "Message: " & SubItems.Message
    TextFile.WriteLine "RecordNumber: " & SubItems.RecordNumber
    TextFile.WriteLine "SourceName: " & SubItems.SourceName
    TextFile.WriteLine "TimeGenerated: " & SubItems.TimeGenerated
    TextFile.WriteLine "TimeWritten: " & SubItems.TimeWritten
    TextFile.WriteLine "Type: " & SubItems.Type
    TextFile.WriteLine "User: " & SubItems.User
TextFile.WriteLine "********************************************************************"
Next
TextFile.Close
OutFile.Run "notepad.exe c:\Win32_NTLogEvent.txt",1,True


Download this snippet    Add to My Saved Code

Get the Events of all Log File using Win32_NTLogEvent WMI Class Comments

No comments have been posted about Get the Events of all Log File using Win32_NTLogEvent WMI Class. Why not be the first to post a comment about Get the Events of all Log File using Win32_NTLogEvent WMI Class.

Post your comment

Subject:
Message:
0/1000 characters