Win32_OperatingSystem collection cannot be iterated

A

Andrew Aronoff

On a few fully-patched XP Pro SP2 systems, the following pseudo-code
throws error 0x80041013:

=====PSEUDO-CODE STARTS HERE=====

Dim oReg : Set oReg = GetObject("winmgmts:root\default:StdRegProv")

'diagnostic point 0

Dim colOS : Set colOS = GetObject("winmgmts:\root\cimv2").ExecQuery _
("Select * from Win32_OperatingSystem")

'diagnostic point 1

On Error Resume Next

For Each oOS in colOS
[test stuff here]
Next

'diagnostic point 2

On Error Goto 0

=====PSEUDO-CODE ENDS HERE=====

If the "On Error Resume Next" line is suppressed, the error message is
reported at the "For Each" line.

At diagnostic point 0, no error is reported, The "Windows Management
Instrumentation" service is running. The local WMI database (in
%SystemRoot%\System32\Wbem\Repository) has been rebuilt without
effect.

At diagnostic point 1:
VarType(colOS) = 9 'colOS is an object, as expected

At diagnostic point 2 with "On Error Resume Next":
Err.Number = 424
Err.Description = Object required

1. Is there a problem in the script code that could explain this
error?

2. Is there any other diagnostic information I could gather to
troubleshoot this problem?

regards, Andy
--
**********

Please send e-mail to: usenet (dot) post (at) aaronoff (dot) com

To identify everything that starts up with Windows, download
"Silent Runners.vbs" at www.silentrunners.org

**********
 
A

Andrew Aronoff

1. Is there a problem in the script code that could explain this
error?
No.

2. Is there any other diagnostic information I could gather to
troubleshoot this problem?

Yes. The best way to proceed is to download the MS WMIDiag tool here:
http://tinyurl.com/g3p4z

The downloaded .EXE file contains WMIDiag.vbs, which produces a
lengthy log (about 1 MB) that can identify the problem in the WMI
installation.

For the PC in question, six DLLs in %WINDIR%\system32\wbem were
incorrectly registered. For the record, those files were:

CIMWIN32.DLL
EVNTRPRV.DLL
WMIPCIMA.DLL
WMIPDSKQ.DLL
WMIPIPRT.DLL
WMIPSESS.DLL

Once the files were re-registered with REGSVR32, WMI was able to
iterate W32_OperatingSystem.

regards, Andy

Andrew Aronoff said:
On a few fully-patched XP Pro SP2 systems, the following pseudo-code
throws error 0x80041013:

=====PSEUDO-CODE STARTS HERE=====

Dim oReg : Set oReg = GetObject("winmgmts:root\default:StdRegProv")

'diagnostic point 0

Dim colOS : Set colOS = GetObject("winmgmts:\root\cimv2").ExecQuery _
("Select * from Win32_OperatingSystem")

'diagnostic point 1

On Error Resume Next

For Each oOS in colOS
[test stuff here]
Next

'diagnostic point 2

On Error Goto 0

=====PSEUDO-CODE ENDS HERE=====

If the "On Error Resume Next" line is suppressed, the error message is
reported at the "For Each" line.

At diagnostic point 0, no error is reported, The "Windows Management
Instrumentation" service is running. The local WMI database (in
%SystemRoot%\System32\Wbem\Repository) has been rebuilt without
effect.

At diagnostic point 1:
VarType(colOS) = 9 'colOS is an object, as expected

At diagnostic point 2 with "On Error Resume Next":
Err.Number = 424
Err.Description = Object required

1. Is there a problem in the script code that could explain this
error?

2. Is there any other diagnostic information I could gather to
troubleshoot this problem?

regards, Andy

--
**********

Please send e-mail to: usenet (dot) post (at) aaronoff (dot) com

To identify everything that starts up with Windows, download
"Silent Runners.vbs" at www.silentrunners.org

**********
 

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