WMI unint32 coming out as int

Hi All,

Pretty new to WMI and vbscript

I have the following:
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

arrComputers = Array(.)
For Each strComputer In arrComputers
   WScript.Echo
   WScript.Echo "=========================================="
   WScript.Echo "Computer: " & strComputer
   WScript.Echo "=========================================="

   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2\NV")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM SyncTopology", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)

   For Each objItem In colItems
      WScript.Echo "id: " & objItem.id
      WScript.Echo
   Next
Next

Open in new window


The result is an id: -2147086205

The range for an int is from -2147086205 to 2147086205

I know from nvidia's documentation the id is an unint32, which goes from 0 to 429467295

What gives? What can I do to the id to get the correct number?
acrouch817Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

printnix63Commented:
I changed only the definition of variable arrComputers into
arrComputers = Array(".")
as otherwise I get an error that line 4 is expecting something different.

When doing this, then I get a value of: 2147749902
C:\test\WMI>cscript //E:vbscript test.vbs
Microsoft (R) Windows Script Host, Version 5.8
Copyright (C) Microsoft Corporation 1996-2001. Alle Rechte vorbehalten.


==========================================
Computer: .
==========================================
C:\test\WMI\test.vbs(11, 4) (null): 0x8004100E

Open in new window

0
acrouch817Author Commented:
Thanks for the response...

Sorry my actuall code is:

'On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

arrComputers = Array("TEST1", "TEST2")
For Each strComputer In arrComputers
   WScript.Echo
   WScript.Echo "=========================================="
   WScript.Echo "Computer: " & strComputer
   WScript.Echo "=========================================="

   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2\NV")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM SyncTopology", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)

   For Each objItem In colItems
      WScript.Echo "id: " & objItem.id
   Next

Open in new window



The output is:

C:\Users\Administrator>cscript test3.vbs
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.


==========================================
Computer: TEST1
==========================================
id: -2147086205


==========================================
Computer: TEST2
==========================================
id: -2147086205


maybe there is a reason why my values are wrong and yours are right?? I know that I am able to connect to the remote computer because it is in the same domain and I can query other attributes (displaySyncState) which return the correct value....:/
0
printnix63Commented:
Hi,

ok, even though I have an NVidia Chip set it does not have the WMI Interface to really get to it, generally speaking, on my computer the script is bailing out before actually dumping the variables you request. On the other hand I have tested now with other variables and I do not see that there is a limitation of the variables as such as vbscript is anyway not so strict on types.

There is a Technet Site from MS that has loads of examples for above that might help a bit, important is, that WMI is picky about the object types you use and the names !
Have a look here:
http://msdn.microsoft.com/en-us/library/aa394587%28v=vs.85%29.aspx

I have modified your script to read out the Processor ID and cycles - just to verify that in principle it would work, and it works well, so check if the objects are read out correctly.

==========================================
Computer: .
==========================================
 id: BFEBFBFF000206A7 Max Clock: 2195

Besides your 2nd example misses a Next at the end, but it's rather obvious probably missed a line when copying it.

Below Code retrieves the Processor ID and Cycles as well if I'd use two names, so basically I am sure the objItem / colItem loop has an issue.

BTW: If you check in control panel, is there a NVIDIA WMI entry to be found? (Just to double check)


Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

arrComputers = Array(".")
For Each strComputer In arrComputers
   WScript.Echo
   WScript.Echo "=========================================="
   WScript.Echo "Computer: " & strComputer
   WScript.Echo "=========================================="
   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
'   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2\NV")
'   Set colItems = objWMIService.ExecQuery("SELECT * FROM SyncTopology") ', "WQL", _
                                          ' wbemFlagReturnImmediately + wbemFlagForwardOnly)
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Processor")
   
   For Each objItem In colItems
      WScript.Echo  " id: " & objItem.ProcessorId & " Max Clock: " & objItem.MaxClockSpeed
   Next
Next 

Open in new window

0
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

acrouch817Author Commented:
Hello, yes nvidia WMI is installed....

You are correct I think that the loop is bad so I tried:

arrComputers = Array("TEST1", "TEST2")
For Each strComputer In arrComputers
   WScript.Echo
   WScript.Echo "=========================================="
   WScript.Echo "Computer: " & strComputer
   WScript.Echo "=========================================="

   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2\NV")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM SyncTopology", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)

      WScript.Echo "id: " & colItems.id
Next

Open in new window


With the same result....

I attached the help file, just don't know how to display the id in the SyncTopology class..... :(
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
acrouch817Author Commented:
retry attachment...
change extension from txt to chm

Also when I say 'same result' i mean still the negative number..
nvwmi.txt
0
acrouch817Author Commented:
Number was actually two's complement of actual number, close help though
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.