WMI Auotomation Error

J

Jack Leach

Hello. I'm trying to get some OS info per the following link:

http://accesstips.wordpress.com/200...formation-using-microsoft-access-vba-and-wmi/

However, I am getting an error on line 23 of sub ListWMIPropsAndValues

Set objWMIService = GetObject("winmgmts:\\" & strComputer & strWMINamespace
& strWMIQuery)

Error -2147217392 (Automation error)


I suspect this may have something to do with the WQL being passed as:

:Win32_OperatingSystem.Name='Microsoft® Windows Vista™ Home Premium
|C:\Windows|\Device\Harddisk0\Partition1'

but all attempts to reconcile have failed.

Is anyone familiar with this, or should I refer to a vista OS board.

Access 2003, Vista Home Premium
Sample download results in the same error

thanks,

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
H

hunterpaw via AccessMonster.com

Hi Jack,

I think you are right about the problem. Most likely one or more of the
characters in the Name Property in the WQL Query is causing the problem. I
have had the same problem myself.

You can get Operating System data by using the procedure below. You can call
it like this:

Call GetWMIMOF("Win32_OperatingSystem")

Function GetWMIMOF(strClass As String) As String

Dim objWMIService As Object
Dim colItems As Object
Dim objItem As Object
Dim strComputer As String
Dim strMOF As String

On Error Resume Next

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" _
& strComputer & "\root\CIMV2")

Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM " & strClass, , 48)

' There is usually only one instance of the Operating System.
' unless you have another instance of an Operating System
' in virtual or sandbox mode
For Each objItem In colItems
strMOF = strMOF & objItem.GetObjectText_
Next

GetWMIMOF = strMOF
Debug.Print strMOF

Set objItem = Nothing
Set colItems = Nothing
Set objWMIService = Nothing

End Function

Best Regards,
Patrick Wood
http://gainingaccess.net/
 
J

Jack Leach

Thanks Patrick, I'll give this a shot within the next few days and see what
it comes up with.

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top