Darktan Posted March 17, 2009 Posted March 17, 2009 I'm coding some hardware and software inventory software. One of the issues I'm running up against is finding the number of processors on a server. The problem is the WMI entry I'm looking for doesn't always exist and if it doesn't, it bombs out the script. (\root\CIMV2 and looking for $objItem.NumberOfLogicalProcessors and $objItem.NumberOfProcessors) Windows 2003 server did not have that WMI entry when it first came out. It has since been added via KB932370. Now I could search for that KB to be installed or check the service pack level, but an easier way in my mind is to just look for the WMI entry. Problem is I don't know how to code it. I'm just getting into WMI. Can this be done? Once I get some data back, I hopefully will be patching everything to be the same and this won't be an issue. Peace --Darktan
ProgAndy Posted March 17, 2009 Posted March 17, 2009 you should use a COM-Errorhandler: $objComError = ObjEvent ( "AutoIt.Error", "_COMError" ) Func _COMError() SetError($objComError.number) EndFunc *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
Darktan Posted March 18, 2009 Author Posted March 18, 2009 AHA! Exactly what I needed. Thank you. Still new to WMI and COM stuff. So all this new learning will make my scripts that much better or that much more complex and shaky. I can't wait to find out which way it goes. Thanks again. Peace
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