I'm stumped and can't seem to find a definitive answer. I'm trying to get a list of network adapters via WMI. The command I've been using has been working fine for almost all the workstations in our office with no problem. Yesterday, problem. One machine fails out. Since its run directly on the users machine, I don't have to explicitly put their machine name and thus using just the "." for local machine. Then, I don't care about the "who", so there's no impersonation going on either. The user should be able to query their own equipment resources. What I WAS using was...
oWMIService = GETOBJECT("winmgmts:\\.\root\cimv2")
oItems = oWMIService.ExecQuery("Select * from Win32_NetworkAdapter",,48)
From what I've found, some places say to remove the "\" for the machine path reference. If I do that, MY machine fails, still no result on the other machine in question. So, I've even tried just going to the root for the service and THAT fails too.
oWMIService = GETOBJECT("winmgmts:\\.")
The actual error I'm getting is...
Error Code: 0x800401ea: Moniker cannot open file.
I've done some searching on this moniker error, but don't know how to get resolution.
Sometimes WMI gets corrupted and confused. Options you could try are:
Re-register/re-compile the WMI components with a batch script like this:
net stop winmgmt
cd /d %windir%\system32\wbem\
for %i in (*.dll) do RegSvr32 /s %i
for %i in (*.mof, *.mfl) do Mofcomp %i
net start winmgmt
If that doesn't solve it, do a reset of the WMI database with this batch:
net stop winmgmt
cd /d %windir%\system32\wbem\
rmdir /s /q Repository
rmdir /s /q Logs
mkdir Logs
net start winmgmt
And/or try a tool like the WMIDiag.vbs script to see if it has suggestions for you.
User contributions licensed under CC BY-SA 3.0