Solved

Programmatically Identifying difference between Desktop and Laptop

Posted on 2004-09-23
2
1,004 Views
Last Modified: 2008-02-01
Does anyone know if there might be a way to identify the difference between a desktop and a laptop programmatically.
I'm open to any suggestion using WMI, WSH, Registry, Files, etc. (even external apps).
0
Comment
Question by:xy15973
2 Comments
 
LVL 3

Expert Comment

by:thunder_moose
ID: 12131367
Hi there,

Yes this is possible with WMI. The code to do it is as follows:

Dim oEnclosures, oEnclosure, iEncType

Set oEnclosures = GetObject("winmgmts:").InstancesOf("Win32_SystemEnclosure")
For Each oEnclosure In oEnclosures
     iEncType = oEnclosure.ChassisTypes(0)
     If num = 3 then
        MsgBox "This is a desktop"
     Else
        If Num = 9 Then MsgBox "This is a laptop"
     End If
Next

The values for Enclose type is as follows:
1 = Other
2 = Unknown
3 = Desktop
4 = Low Profile Desktop
5 = Pizza Box
6 = Mini Tower
7 = Tower
8 = Portable
9 = Laptop
10 = Notebook
11 = Hand Held
12 = Docking Station
13 = All in One
14 = Sub Notebook
15 = Space-Saving
16 = Lunch Box
17 = Main System Chassis
18 = Expansion Chassis
19 = Sub Chassis
20 = Bus Expansion Chassis
21 = Peripheral Chassis
22 = Storage Chassis
23 = Rack Mount Chassis
24 = Sealed-Case PC

So you might have to change it to something like
If num >= 7 Then Desktop
If (num >=8) and (num <= 14) Then Laptop
Or something to that effect.

To run, paste in a text file, tweak to your liking, save as .vbs and run from the command line with: cscript filename.vbs

Hope that helps,
TM
0
 
LVL 1

Accepted Solution

by:
martin_watts earned 500 total points
ID: 12131429
There are two differences between desktops and laptops that are quite easy to detect. One is the presence of a PCMIA slot, the other is the existence of multiple hardware configurations (docked and undocked).

The existence of PCMIA ports is probably the easiest to detect. In the registry, you can look for the key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PCMIA. If it exists, the machine has PCMIA ports and therefor must be a laptop.

You can also look in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Pcmia. This key exists on both desktops and laptops, but the latter have a subkey for each enabled PCMIA slot (0000, 0001, 0002 etc.)

Note that the above mentioned keys exist on a Windows NT/2000 system. On older Windows 98 type systems, the keys you would be looking for could be stored differently.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now