如何解决“OLE IDispatch 异常代码0 出自 SWbemlocator:依赖服务或组无法启动”?
现有如下代码段:Local oWMI As Object,oLocal As Object,oHARDWARE As Object,object1 As Object
oWMI=Createobject("WbemScripting.SWbemLocator")
oLocal=oWMI.ConnectServer(".", "root\cimv2")
oHARDWARE=oLocal.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled=1")
For Each object1 In oHARDWARE
LcIP=object1.Properties_('IPAddress').Value
Exit
Endfor
?'IP地址:',LcIP
在执行第三行 “oLocal=oWMI.ConnectServer(".", "root\cimv2") ”是出错,错误提示内容为“OLE IDispatch 异常代码0 出自 SWbemlocator:依赖服务或组无法启动”。
该问题困扰许久,不知道如何解决,请大侠支招。谢谢!!