Solved

Programmatically Identifying difference between Desktop and Laptop

Posted on 2004-09-23
2
1,009 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 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

15 Experts available now in Live!

Get 1:1 Help Now