Bowmore Posted July 2, 2012 Share Posted July 2, 2012 (edited) Hi I'm looking for a function that will return the number of cores present on a PC and if the processor has Hyperthreading the number of CPUs as displayed in Task Manager. For example: 2 core processor without hyperthreading would return 2 4 core processor without hyperthreading would return 4 6 core processor with hyperthreading would return 12 8 core processor with hyperthreading would return 16 I've been searching the forum and example scripts and not found what I'm looking for so far. If someone knows of such a function Id be greatful for a pointer to it. Thanks Edited July 2, 2012 by Bowmore "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
BrewManNH Posted July 2, 2012 Share Posted July 2, 2012 Something like this perhaps? ; Generated by AutoIt Scriptomatic July 02, 2012 $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $Output &= "Computer: " & $strComputer & @CRLF $Output &= "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:" & $strComputer & "ROOTCIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $Output &= "NumberOfCores: " & $objItem.NumberOfCores & @CRLF $Output &= "NumberOfLogicalProcessors: " & $objItem.NumberOfLogicalProcessors & @CRLF if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop $Output="" Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Processor" ) Endif If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Tripredacus Posted July 2, 2012 Share Posted July 2, 2012 Crap, beat me to it BrewMan. Twitter | MSFN | VGCollect Link to comment Share on other sites More sharing options...
BrewManNH Posted July 2, 2012 Share Posted July 2, 2012 The scriptomatic tool makes it easy to come up with this kind of script, all I needed to do was to eliminate all the other crap that's known about the processor to get to this. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Bowmore Posted July 2, 2012 Author Share Posted July 2, 2012 Thanks Guys "NumberOfLogicalProcessors" was the name I could not remember. Now that I know what I was supposed to be looking for I found a function similar to the one given by BrewManH on my PC in a script I wrote 3 years ago. I think I need to get a new search function for my ageing brain. "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
UEZ Posted July 2, 2012 Share Posted July 2, 2012 Remark: NumberOfLogicalProcessors is only available on Vista+ operating systems. Br,UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
BrewManNH Posted July 2, 2012 Share Posted July 2, 2012 Here's some follow-up information in regards to what UEZ mentions:Windows Server 2003, Windows XP, and Windows 2000: Because the NumberOfLogicalProcessors property is not available, NumberOfProcessors indicates the number of logical processors available in the system. In the case of a computer system that has two physical processors each containing two logical processors, the value of NumberOfProcessors is 4. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Bowmore Posted July 2, 2012 Author Share Posted July 2, 2012 The NumberOfLogicalProcessors property is available on some versions of XP. I just used it on several PCs at work (XP profesional SP3) and the expected values are returned without any errors. I believe Microsoft made this available to XP in SP3 "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook 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