guysa Posted April 17, 2013 Share Posted April 17, 2013 I'm trying to convert this WMI script to AU3 Thanks, Guy Sasson On Error Resume Next Const wbemFlagReturnImmediately = &h10 Const wbemFlagForwardOnly = &h20 arrComputers = Array(".") For Each strComputer In arrComputers Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_SystemEnclosure", "WQL", _ wbemFlagReturnImmediately + wbemFlagForwardOnly) For Each objItem In colItems strChassisTypes = Join(objItem.ChassisTypes, ",") Select Case strChassisTypes Case 1 Wscript.Echo "Other" Case 2 Wscript.Echo "Unknown" Case 3 Wscript.Echo "Desktop" Case 4 Wscript.Echo "Low Profile Desktop" Case 5 Wscript.Echo "Pizza Box" Case 6 Wscript.Echo "Mini Tower" Case 7 Wscript.Echo "Tower" Case 8 Wscript.Echo "Portable" Case 9 Wscript.Echo "Laptop" Case 10 Wscript.Echo "Notebook" Case 11 Wscript.Echo "Handheld" Case 12 Wscript.Echo "Docking Station" Case 13 Wscript.Echo "All-in-One" Case 14 Wscript.Echo "Sub-Notebook" Case 15 Wscript.Echo "Space Saving" Case 16 Wscript.Echo "Lunch Box" Case 17 Wscript.Echo "Main System Chassis" Case 18 Wscript.Echo "Expansion Chassis" Case 19 Wscript.Echo "Sub-Chassis" Case 20 Wscript.Echo "Bus Expansion Chassis" Case 21 Wscript.Echo "Peripheral Chassis" Case 22 Wscript.Echo "Storage Chassis" Case 23 Wscript.Echo "Rack Mount Chassis" Case 24 Wscript.Echo "Sealed-Case PC" Case Else Wscript.Echo "Unknown" End Select Next Next Link to comment Share on other sites More sharing options...
water Posted April 17, 2013 Share Posted April 17, 2013 Please have a look at ScriptOmatic in the Example Scripts forum. Select WMI Class "Win32_SystemEnclosure" and Scriptomatic will generate te AutoIt code for you. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
FireFox Posted April 17, 2013 Share Posted April 17, 2013 Hi,Welcome to the autoit forum From a forum search : Br, FireFox. Link to comment Share on other sites More sharing options...
kylomas Posted April 17, 2013 Share Posted April 17, 2013 guysa, This was translated from the code you posted using Scriptomatic (as water advised)... expandcollapse popupLocal $wbemFlagReturnImmediately = 0x10 Local $wbemFlagForwardOnly = 0x20 $oWMISvc = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2") $colItems = $oWMISvc.ExecQuery("SELECT * FROM Win32_SystemEnclosure", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) For $objItem In $colItems Switch $objItem.ChassisTypes(0) Case 1 ConsoleWrite('Other' & @LF) Case 2 ConsoleWrite("Unknown" & @LF) Case 3 ConsoleWrite("Desktop" & @LF) Case 4 ConsoleWrite("Low Profile Desktop" & @LF) Case 5 ConsoleWrite("Pizza Box" & @LF) Case 6 ConsoleWrite("Mini Tower" & @LF) Case 7 ConsoleWrite("Tower" & @LF) Case 8 ConsoleWrite("Portable" & @LF) Case 9 ConsoleWrite("Laptop" & @LF) Case 10 ConsoleWrite("Notebook" & @LF) Case 11 ConsoleWrite("Handheld" & @LF) Case 12 ConsoleWrite("Docking Station" & @LF) Case 13 ConsoleWrite("All-in-One" & @LF) Case 14 ConsoleWrite("Sub-Notebook" & @LF) Case 15 ConsoleWrite("Space Saving" & @LF) Case 16 ConsoleWrite("Lunch Box" & @LF) Case 17 ConsoleWrite("Main System Chassis" & @LF) Case 18 ConsoleWrite("Expansion Chassis" & @LF) Case 19 ConsoleWrite("Sub-Chassis" & @LF) Case 20 ConsoleWrite("Bus Expansion Chassis" & @LF) Case 21 ConsoleWrite("Peripheral Chassis" & @LF) Case 22 ConsoleWrite("Storage Chassis" & @LF) Case 23 ConsoleWrite("Rack Mount Chassis" & @LF) Case 24 ConsoleWrite("Sealed-Case PC" & @LF) Case Else ConsoleWrite("Unknown" & @LF) EndSwitch next kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now