Jump to content

Win32_SystemEnclosure not returning correct number


Recommended Posts

Hello,

I am using the .29 beta version of AutoIT and I am trying to figure out if a script is being run on a Laptop or Desktop. I found a list of the valid returns from the Win32_SystemEnclosure for VBScript which is below. When I pull up the ScriptOMatic from microsoft and run the VBScript for the Win32_SystemEnclosure it returns a 3 for enclosure type. When I pull up the Win32_SystemEnclosure from the AU3 ScriptOmatic it returns 1244292 for the Chassis Type which shockingly is not on this list. Does anyone have any ideas?

1 Then PCkind = "Other" ' Could use Virtual here for VM machine. 'VM machines have in my testing always pulled this Category.

2 Then PCkind = "Unknown"

3 Then PCkind = "Desktop"

4 Then PCkind = "Low Profile Desktop"

5 Then PCkind = "Pizza Box"

6 Then PCkind = "Mini Tower"

7 Then PCkind = "Tower"

8 Then PCkind = "Portable"

9 Then PCkind = "Laptop"

10 Then PCkind = "Notebook"

11 Then PCkind = "Hand Held"

12 Then PCkind = "Docking Station"

3 Then PCkind = "All in One"

14 Then PCkind = "Sub Notebook"

15 Then PCkind = "Space-Saving"

16 Then PCkind = "Lunch Box"

17 Then PCkind = "Main System Chassis"

18 Then PCkind = "Expansion Chassis"

19 Then PCkind = "SubChassis"

20 Then PCkind = "Bus Expansion Chassis"

21 Then PCkind = "Peripheral Chassis"

22 Then PCkind = "Storage Chassis"

23 Then PCkind = "Rack Mount Chassis"

24 Then PCkind = "Sealed-Case PC"

Thanks,

Mike

Edited by MikeOsdx
Link to comment
Share on other sites

OK,

I got it returning the proper numbers thanks to qafrost but Now I am wondering if there is any way to shrink up the code at all. This is what I have been able to compress it down to so far but I am wondering if there is any way to get rid of the For Next loop since I am only trying to pull the One item. "Sorry if this is a dumb question but I am stumbling my way through this"

$Output=""
$objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_SystemEnclosure", "WQL", 0x10 + 0x20)

If IsObj($colItems) then
    For $objItem In $colItems
      $strChassisTypes = $objItem.ChassisTypes(0)
      $Output = $Output & "ChassisTypes: " & $strChassisTypes & @CRLF
      if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
   Next
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_SystemEnclosure" )
Endif

Thanks for the help,

Mike

Link to comment
Share on other sites

OK,

I got it returning the proper numbers thanks to qafrost but Now I am wondering if there is any way to shrink up the code at all.  This is what I have been able to compress it down to so far but I am wondering if there is any way to get rid of the For Next loop since I am only trying to pull the One item.  "Sorry if this is a dumb question but I am stumbling my way through this"

...

Thanks for the help,

Mike

<{POST_SNAPBACK}>

Hello Mike,

The scriptomatic.au3 in 'script and scrapts' forum has been updated to fix the (0) bug.

About pulling one item: According to the Microsoft docs (http://msdn.microsoft.com/library/en-us/wmisdk/wmi/swbemobjectset_item.asp) it should be like: $ObjItem=$ColItems.Item("System Enclosure 0")

But that does not seem to work on 'System enclosures'.

So keeping the FOR..IN and only replacing the 'MsgBox..' line with 'Exitloop' will also do the job.

Regards,

-Sven

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...