{"id":71393,"date":"2004-09-21T11:34:00","date_gmt":"2004-09-21T11:34:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2004\/09\/21\/how-can-i-determine-if-a-computer-is-a-laptop-or-a-desktop-machine\/"},"modified":"2004-09-21T11:34:00","modified_gmt":"2004-09-21T11:34:00","slug":"how-can-i-determine-if-a-computer-is-a-laptop-or-a-desktop-machine","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-determine-if-a-computer-is-a-laptop-or-a-desktop-machine\/","title":{"rendered":"How Can I Determine if a Computer is a Laptop or a Desktop Machine?"},"content":{"rendered":"<p><img decoding=\"async\" class=\"nearGraphic\" title=\"Hey, Scripting Guy! Question\" border=\"0\" alt=\"Hey, Scripting Guy! Question\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" height=\"34\"><\/p>\n<p>Hey, Scripting Guy! Is there any way to use WMI to determine whether a computer is a laptop or a desktop machine?<\/p>\n<p>&#8212; CB<\/p>\n<p><img decoding=\"async\" border=\"0\" alt=\"Spacer\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/05\/spacer.gif\" width=\"5\" height=\"5\"><img decoding=\"async\" class=\"nearGraphic\" title=\"Hey, Scripting Guy! Answer\" border=\"0\" alt=\"Hey, Scripting Guy! Answer\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" height=\"34\"><a href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=68779&amp;clcid=0x409\"><img decoding=\"async\" class=\"farGraphic\" title=\"Script Center\" border=\"0\" alt=\"Script Center\" align=\"right\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/ad.jpg\" width=\"120\" height=\"288\"><\/a><\/p>\n<p>Hey, CB. You bet there is, although if you didn\u2019t know that we have no idea how you\u2019d figure it out on your own. It turns out there\u2019s a goofy little WMI class called Win32_SystemEnclosure, and the ChassisTypes property can tell you whether a computer is a laptop, a desktop, or some other kind of top. Uh, type. Here a script that tells you what type of chassis you\u2019re dealing with:<\/p>\n<pre class=\"codeSample\">strComputer = \".\"\nSet objWMIService = GetObject(\"winmgmts:\" _\n    &amp; \"{impersonationLevel=impersonate}!\\\\\" &amp; strComputer &amp; \"\\root\\cimv2\")\nSet colChassis = objWMIService.ExecQuery _\n    (\"Select * from Win32_SystemEnclosure\")\nFor Each objChassis in colChassis\n    For  Each strChassisType in objChassis.ChassisTypes\n        Wscript.Echo strChassisType\n    Next\nNext\n<\/pre>\n<p>Ok, so the preceding script only <i>kind of <\/i>tells you what type of chassis you\u2019re dealing with. The ChassisType property actually returns a number, which means when we run the script on the computer sitting here in front of us we get back a 10. What\u2019s a 10? According to the <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/wmisdk\/wmi\/win32_systemenclosure.asp\"><b>WMI SDK<\/b><\/a>, that means this is a notebook computer. And guess what? It is!<\/p>\n<p>But you don\u2019t have to refer to the SDK each time you check the chassis type. Here\u2019s an expanded version of the script that uses a Select Case statement to convert these integers to something a bit more meaningful:<\/p>\n<pre class=\"codeSample\">strComputer = \".\"\nSet objWMIService = GetObject(\"winmgmts:\" _\n    &amp; \"{impersonationLevel=impersonate}!\\\\\" &amp; strComputer &amp; \"\\root\\cimv2\")\nSet colChassis = objWMIService.ExecQuery _\n    (\"Select * from Win32_SystemEnclosure\")\nFor Each objChassis in colChassis\n    For  Each strChassisType in objChassis.ChassisTypes\n        Select Case strChassisType\n            Case 1\n                Wscript.Echo \"Other\"\n            Case 2\n                Wscript.Echo \"Unknown\"\n            Case 3\n                Wscript.Echo \"Desktop\"\n            Case 4\n                Wscript.Echo \"Low Profile Desktop\"\n            Case 5\n                Wscript.Echo \"Pizza Box\"\n            Case 6\n                Wscript.Echo \"Mini Tower\"\n            Case 7\n                Wscript.Echo \"Tower\"\n            Case 8\n                Wscript.Echo \"Portable\"\n            Case 9\n                Wscript.Echo \"Laptop\"\n            Case 10\n                Wscript.Echo \"Notebook\"\n            Case 11\n                Wscript.Echo \"Handheld\"\n            Case 12\n                Wscript.Echo \"Docking Station\"\n            Case 13\n                Wscript.Echo \"All-in-One\"\n            Case 14\n                Wscript.Echo \"Sub-Notebook\"\n            Case 15\n                Wscript.Echo \"Space Saving\"\n            Case 16\n                Wscript.Echo \"Lunch Box\"\n            Case 17\n                Wscript.Echo \"Main System Chassis\"\n            Case 18\n                Wscript.Echo \"Expansion Chassis\"\n            Case 19\n                Wscript.Echo \"Sub-Chassis\"\n            Case 20\n                Wscript.Echo \"Bus Expansion Chassis\"\n            Case 21\n                Wscript.Echo \"Peripheral Chassis\"\n            Case 22\n                Wscript.Echo \"Storage Chassis\"\n            Case 23\n                Wscript.Echo \"Rack Mount Chassis\"\n            Case 24\n                Wscript.Echo \"Sealed-Case PC\"\n            Case Else\n                Wscript.Echo \"Unknown\"\n            End Select\n    Next\nNext\n<\/pre>\n<p>Before you ask, no, we don\u2019t really know what most of these chassis types are, nor do we know what the difference is between a portable, a laptop, and a notebook. We also don\u2019t know why the ChassisTypes property is stored as an array. Does that mean a computer could have more than one chassis type? Don\u2019t ask us; we don\u2019t know. But give us a break: after all, we\u2019re the Microsoft <i>Scripting <\/i>Guys, not the Microsoft Hardware Guys!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! Is there any way to use WMI to determine whether a computer is a laptop or a desktop machine? &#8212; CB Hey, CB. You bet there is, although if you didn\u2019t know that we have no idea how you\u2019d figure it out on your own. It turns out there\u2019s a goofy little [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[33,34,3,5],"class_list":["post-71393","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-basic-hardware-and-firmware","tag-hardware","tag-scripting-guy","tag-vbscript"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! Is there any way to use WMI to determine whether a computer is a laptop or a desktop machine? &#8212; CB Hey, CB. You bet there is, although if you didn\u2019t know that we have no idea how you\u2019d figure it out on your own. It turns out there\u2019s a goofy little [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/71393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=71393"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/71393\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=71393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=71393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=71393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}