Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use vbs to determine whether a computer is a laptop or a desktop

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces "how to use vbs to judge whether a computer is a notebook or a desktop". In daily operation, I believe many people have doubts about how to use vbs to judge whether a computer is a notebook or a desktop. The editor consulted all kinds of materials and sorted out a simple and easy-to-use method of operation. I hope it will be helpful for everyone to answer the doubt of "how to use vbs to judge whether a computer is a notebook or a desktop." Next, please follow the editor to study!

The ChassisTypes property can tell you whether you are using a laptop, desktop, or other type of computer. Oh, enter. The following script lets you know what type of computer you are using:

The copy code is as follows:

StrComputer = "."

Set objWMIService = GetObject ("winmgmts:" _

& "{impersonationLevel=impersonate}!\" & strComputer & "\ root\ cimv2")

Set colChassis = objWMIService.ExecQuery _

("Select * from Win32_SystemEnclosure")

For Each objChassis in colChassis

For Each strChassisType in objChassis.ChassisTypes

Wscript.Echo strChassisType

Next

Next

Well, the above script only lets you know to some extent what type of computer you are using. In fact, the ChassisType property returns a number, which means that when we run the script on the computer in front of us, we will get 10. So, what is 10? According to WMI SDK, it refers to a laptop computer. Guess what will happen? That's right!

However, you don't have to refer to SDK every time you check your computer type. The following expanded script uses a Select Case statement that converts these integers into something more meaningful:

The copy code is as follows:

StrComputer = "."

Set objWMIService = GetObject ("winmgmts:" _

& "{impersonationLevel=impersonate}!\" & strComputer & "\ root\ cimv2")

Set colChassis = objWMIService.ExecQuery _

("Select * from Win32_SystemEnclosure")

For Each objChassis in colChassis

For Each strChassisType in objChassis.ChassisTypes

Select Case strChassisType

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

At this point, the study on "how to use vbs to judge whether a computer is a laptop or a desktop computer" is over. I hope to be able to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report