Solved

WMI - Getting access to the Event Details?

Posted on 2011-03-07
13
647 Views
Last Modified: 2013-12-04
New to WMI.  Have googled a while today, but no luck.

I am generating an error with MySQL (see screenshot attached).

I can get access to a lot of the event info using:
Select * from Win32_NTLogEvent where Type ='Error' and SourceName = 'MySQL'

But I can't seem to get my hands on what I really care about, which is shown in the log viewer in the "box" in the General tag.

I want to get that message "Plugin 'InnoDB' registration as a STORAGE ENGINE failed."

How can I using a WMI query?
0
Comment
Question by:trippy1976
  • 6
  • 5
  • 2
13 Comments
 
LVL 26

Expert Comment

by:EDDYKT
ID: 35068603
0
 
LVL 4

Author Comment

by:trippy1976
ID: 35069484
I forgot to attach the screenshot of the event log viewer.  Also attaching the saved results of my WMI query.  

No, it's sadly not in the Message field... that would be trivial.  I think this is more involved.

Screenshot of the event viewerresult.htm
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 35070496
Did you look at the other properties for the Win32_NTLogEvent?

Win32_NTLogEvent Class
http://msdn.microsoft.com/en-us/library/aa394226(v=vs.85).aspx

Is that information in the Data property?
0
 
LVL 4

Author Comment

by:trippy1976
ID: 35070758
Yes.  The data is in "InsertionStrings"

I need the information from that object in a WQL query.  

The html doc I attached shows all the properties and their resulting values.  If it were avaialble in a top-level property I wouldn't be posting here :)  Thanks for the help, but I fear the answer to this is "it can't be done"
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 35070970
InsertionStrings is a string array, so you should be able to get that information from the Win32_NTLogEvent object.
0
 
LVL 26

Assisted Solution

by:EDDYKT
EDDYKT earned 250 total points
ID: 35071000
don't think it supports on WMI, you may want to use API instead
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 4

Author Comment

by:trippy1976
ID: 35071063
@TheLearnedOne - you can, if you are scripting.  If you are simply doing a WQL query I am not sure if it's possible.

I googled forever, then I turned here.  What I really need is the WMI query that will get the pieces of InsertionString info.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 total points
ID: 35071093
Can you show me what you are working with, please?
0
 
LVL 4

Author Closing Comment

by:trippy1976
ID: 35166037
As suspected, you can't query directly to the elements in something like Insertion Strings.  I had to write a VB script to do the query, get the results, and grab that deeper data.  Appears to be the only way to do this.  Thanks everyone.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 35169525
Did you come up with the VB script?
0
 
LVL 4

Author Comment

by:trippy1976
ID: 35169798
Yes.  I found the JoinStringsArray function somewhere on google.
strComputer = "."
Set objWMIService = GetObject _
    ( "winmgmts:\\" & strComputer & "\root\cimv2")
	
Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_NTLogEvent where Type ='Error' and Logfile ='Application' and SourceName='MySQL'")


For Each objItem in colItems     
	strLogString = objItem.TimeGenerated & "," & JoinStringsArray(objItem.InsertionStrings)
Next



Function JoinStringsArray(ByRef aArray)
    If VarType(aArray) = vbNull Then
        JoinStringsArray = ""
        Exit Function
    Else
        JoinStringsArray = Join(aArray)
        JoinStringsArray = Replace(JoinStringsArray, "(NULL)", "")
    End If
End Function

Open in new window

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 35171392
You don't need VBScript to do what you have shown.  I don't see anything that it overly complicated, and not achievable with VB.NET/C#.
0
 
LVL 4

Author Comment

by:trippy1976
ID: 35171464
I'm certain you can do it a number of ways.  I really can't go into the specifics of why I needed a VBScript in this case, but it was my choice for workaround.

There was an existing component that could do direct WMI queries, but since you can't get at the info I need via WMI directly I had to go this route.

0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now