(view source code of islaptop.vbs as plain text)
If IsLaptop( "." ) Then
WScript.Echo "Laptop"
ElseWScript.Echo "Desktop or server"
End If
Function IsLaptop( myComputer )
' This Function checks if a computer has a battery pack.' One can assume that a computer with a battery pack is a laptop.'' Argument:' myComputer [string] name of the computer to check,' or "." for the local computer' Return value:' True if a battery is detected, otherwise False'' Written by Rob van der Woude' http://www.robvanderwoude.comOn Error Resume Next
Set objWMIService = GetObject( "winmgmts://" & myComputer & "/root/cimv2" )
Set colItems = objWMIService.ExecQuery( "Select * from Win32_Battery", , 48 )
IsLaptop = False
For Each objItem in colItems
IsLaptop = True
NextIf Err Then Err.Clear
On Error Goto 0
End Function
page last modified: 2025-10-11; loaded in 0.0082 seconds