Sign in to follow this  
Followers 0
kor

How to tell if computer is a laptop or not?

5 posts in this topic

Is there a way through some kind of query that will return weather or not a workstation is a laptop or desktop? I can look for a particular file that only laptops might have, but I wouldn't know what kind of file that might be.

We have about 6 or 7 different models of laptops at work and we are wanting to exclude a script from running on any of the laptops. We currently have no way in AD to determine if they are mobile computers or not. Plus the laptops are different brands too, gateway, dell, hitachi.. so looking for a particular vendors special files is difficult too.

Is there something that I can query from windows that would report if the device it's on is a laptop or not? Being different vendors I can't think to look at cpu or anything cause each laptop model has different hardware.

Share this post


Link to post
Share on other sites



I was just thinking of trying to see if the computer had a battery or not because every laptop we have would have a battery, regardless of the vendor type.

Is there a way to check if the OS has a battery. Somehow XP is able to activate the battery settings depending on some condition. What would that condition be?

Share this post


Link to post
Share on other sites

Perhaps you could use WMI to pull the info you need ...

$computer = '.'
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20

$oWMIService = ObjGet('winmgmts:\\' & $computer& '\root\CIMV2')
If IsObj($oWMIService) Then
    $colItems = $oWMIService.ExecQuery('SELECT * FROM Win32_ComputerSystem', 'WQL', $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    If IsObj($colItems) Then
        For $oItem In $colItems
            $model = $oItem.Model
        Next
    EndIf
EndIf

Share this post


Link to post
Share on other sites

If this is still relevant..

Here is a script based on WMI query..I have only used some of the Chassis types that are available, but they cover most cases...

**********************************************************

$strComputer = "."

$objWMIService = ObjGet('winmgmts:{impersonationLevel=impersonate}!\\' & $strComputer & "\root\cimv2")

$colChassis = $objWMIService.ExecQuery("Select * from Win32_SystemEnclosure")

For $objChassis in $colChassis

For $strChassisType in $objChassis.ChassisTypes

if $strChassisType = 8 or $strChassisType = 9 or $strChassisType = 10 then msgbox(0, "", "laptop")

if $strChassisType = 3 or $strChassisType = 4 or $strChassisType = 5 or $strChassisType = 6 or $strChassisType = 7 then msgbox(0, "", "Desktop")

Next

next

****************************************************************************

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0