Solved

Programmatically Identifying difference between Desktop and Laptop

Posted on 2004-09-23
2
1,025 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

737 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