Solved

Programmatically Identifying difference between Desktop and Laptop

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

821 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