{"id":37513,"date":"2004-10-21T07:00:00","date_gmt":"2004-10-21T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2004\/10\/21\/let-wmi-do-the-heavy-lifting-of-determining-system-information\/"},"modified":"2004-10-21T07:00:00","modified_gmt":"2004-10-21T07:00:00","slug":"let-wmi-do-the-heavy-lifting-of-determining-system-information","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20041021-00\/?p=37513","title":{"rendered":"Let WMI do the heavy lifting of determining system information"},"content":{"rendered":"<p><P>\n<A HREF=\"http:\/\/msdn.microsoft.com\/library\/en-us\/dnanchor\/html\/anch_wmi.asp\">\nWindows Management Instrumentation<\/A>\nis a scriptable interface to configuration information.\nThis saves you the trouble of having to figure it out yourself.\n<\/P>\n<P>\nFor example, here&#8217;s a little program that enumerates all the CPUs\nin your system and prints some basic information about them.\n<\/P>\n<PRE>\nvar locator = WScript.CreateObject(&#8220;WbemScripting.SWbemLocator&#8221;);\nvar services = locator.ConnectServer();\nvar cpus = new Enumerator(services.ExecQuery(&#8220;SELECT * FROM Win32_Processor&#8221;));\nwhile (!cpus.atEnd()) {\n  var cpu = cpus.item();\n  WScript.StdOut.WriteLine(&#8220;cpu.ProcessorType=&#8221; + cpu.ProcessorType);\n  WScript.StdOut.WriteLine(&#8220;cpu.CurrentClockSpeed=&#8221; + cpu.CurrentClockSpeed);\n  WScript.StdOut.WriteLine(&#8220;cpu.MaxClockSpeed=&#8221; + cpu.MaxClockSpeed);\n  WScript.StdOut.WriteLine(&#8220;cpu.Manufacturer=&#8221; + cpu.Manufacturer);\n  WScript.StdOut.WriteLine();\n  cpus.moveNext();\n}\n<\/PRE>\n<P>\nSave this program as <CODE>cpus.js<\/CODE> and run it via\n<CODE>cscript cpus.js<\/CODE>.\n<\/P>\n<P>\nThere&#8217;s a whole lot of other information kept inside WMI.\nYou can get lost amidst\n<A HREF=\"http:\/\/msdn.microsoft.com\/library\/en-us\/wmisdk\/wmi\/wmi_classes.asp\">\nall the classes that exist<\/A>.\n<A HREF=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/tools\/wmimatic.mspx\">\nThe Scripting Guys<\/A>\nhave their own tool called\n<A HREF=\"http:\/\/www.microsoft.com\/downloads\/details.aspx?displaylang=en&amp;familyid=9ef05cbd-c1c5-41e7-9da8-212c414a7ab0\">\nWMI Scriptomatic<\/A>\nwhich lets you cruise around the WMI namespace.\n(The Scripting Guys also wrote\n<A HREF=\"http:\/\/www.microsoft.com\/technet\/community\/scriptcenter\/tools\/twkmatic.mspx\">\nTweakomatic<\/A>\nwhich comes with hilarious documentation.)\n<\/P>\n<P>\n<B>Added 11am<\/B>:\nIt appears that people have misunderstood the point of this entry.\nThe point here is not to show how to print the results to the screen.\n(I just did that to prove it actually worked.)\nThe point is that you can let\nWMI do the hard work of actually digging up the information\n<I>instead of having to hunt it down yourself<\/I>.\nWant BIOS information?  Try\n<A HREF=\"http:\/\/msdn.microsoft.com\/library\/en-us\/wmisdk\/wmi\/win32_bios.asp\">\nWin32_BIOS<\/A>.  Change the query to &#8220;SELECT * FROM Win32_BIOS&#8221; and\nyou can get the manufacturer from the Manufacturer property.\n<A HREF=\"http:\/\/msdn.microsoft.com\/library\/en-us\/wmisdk\/wmi\/wmi_tasks_for_scripts_and_applications.asp\">\nPlenty more examples in MSDN<\/A>.\n<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Windows Management Instrumentation is a scriptable interface to configuration information. This saves you the trouble of having to figure it out yourself. For example, here&#8217;s a little program that enumerates all the CPUs in your system and prints some basic information about them. var locator = WScript.CreateObject(&#8220;WbemScripting.SWbemLocator&#8221;); var services = locator.ConnectServer(); var cpus = new [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-37513","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Windows Management Instrumentation is a scriptable interface to configuration information. This saves you the trouble of having to figure it out yourself. For example, here&#8217;s a little program that enumerates all the CPUs in your system and prints some basic information about them. var locator = WScript.CreateObject(&#8220;WbemScripting.SWbemLocator&#8221;); var services = locator.ConnectServer(); var cpus = new [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/37513","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=37513"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/37513\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=37513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=37513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=37513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}