wmi not available for some time after reboot
Posted
by
Alex Okrushko
on Stack Overflow
See other posts from Stack Overflow
or by Alex Okrushko
Published on 2012-10-26T14:14:27Z
Indexed on
2012/10/29
17:01 UTC
Read the original article
Hit count: 473
I'm having the problem with the WMI availability on logon.
Right after reboot I open cmd and with python interpreter:
>>> import wmi
>>> c = wmi.WMI()
>>> c.Win32_OperatingSystem()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\wmi.py", line 1147, in __getattr__
return getattr (self._namespace, attribute)
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 516, in
__getattr__
raise AttributeError("%s.%s" % (self._username_, attr))
AttributeError: winmgmts:.Win32_OperatingSystem
>>>
5 minutes later I open another cmd and python interpreter:
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import wmi
>>> c = wmi.WMI()
>>> c.Win32_OperatingSystem()
[<_wmi_object: \\W520-ALEX-WIN7\root\cimv2:Win32_OperatingSystem=@>]
>>>
NOTE: the first cmd still keeps saying AttributeError even 5 minutes later.
NOTE 2: if I logout and login wmi is available, so it is somehow effected by reboot
with process explorer I check the environmental variables and they are the same for both cmds
What could that be? Please help.
UPDATE: Apparently the problem is connecting to the wbem services:
>>> import win32com.client
>>> win32com.client.Dispatch('WbemScripting.SWbemLocator')
<COMObject WbemScripting.SWbemLocator>
>>> wmi_service= win32com.client.Dispatch('WbemScripting.SWbemLocator')
>>> wbem_service = wmi_service.ConnectServer('.','root/cimv2')
>>> wbem_service
<COMObject <unknown>>
>>> items = wbem_service.ExecQuery('Select * from Win32_OperatingSystem')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<COMObject <unknown>>", line 3, in ExecQuery
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 282, in
_ApplyTypes_
result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType, argTypes
) + args)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, u'SWbemServicesEx
', u'Generic failure ', None, 0, -2147217407), None)
>>>
NOTE 3: wmic os
always worked.
NOTE 4: re-installing pywin32 package didn't help. Neither did Re-registering/re-compiling the WMI components and resetting of the WMI database (as recommended here)
NOTE 5: my 4 Other laptops don't have this problem.
Also wmiprov.log has:
(Mon Oct 29 11:40:07 2012.248587) : ***************************************
(Mon Oct 29 11:40:07 2012.248587) : Could not get pointer to binary resource for file:
(Mon Oct 29 11:40:07 2012.248587) : C:\Windows\system32\drivers\ndis.sys[MofResourceName](Mon Oct 29 11:40:07 2012.248587) :
(Mon Oct 29 11:40:07 2012.248587) : ***************************************
(Mon Oct 29 11:40:07 2012.248587) : ***************************************
(Mon Oct 29 11:40:07 2012.248587) : Could not get pointer to binary resource for file:
(Mon Oct 29 11:40:07 2012.248587) : C:\Windows\system32\drivers\en-US\ndis.sys.mui[MofResourceName](Mon Oct 29 11:40:07 2012.248587) :
(Mon Oct 29 11:40:07 2012.248587) : ***************************************
(Mon Oct 29 11:40:07 2012.248603) : ***************************************
(Mon Oct 29 11:40:07 2012.248603) : Could not get pointer to binary resource for file:
(Mon Oct 29 11:40:07 2012.248603) : C:\Windows\system32\DRIVERS\wmiacpi.sys[MofResource](Mon Oct 29 11:40:07 2012.248603) :
(Mon Oct 29 11:40:07 2012.248603) : ***************************************
(Mon Oct 29 11:40:07 2012.248603) : ***************************************
(Mon Oct 29 11:40:07 2012.248603) : Could not get pointer to binary resource for file:
(Mon Oct 29 11:40:07 2012.248603) : C:\Windows\system32\DRIVERS\monitor.sys[MonitorWMI](Mon Oct 29 11:40:07 2012.248603) :
(Mon Oct 29 11:40:07 2012.248603) : ***************************************
NOTE 6: the WMIDiag tool report is at my dropbox
© Stack Overflow or respective owner