' Example VBScript to check if computer is laptop or workstation
' Author Lance Dobbs
' Version 1.1 - July 2009
If IsLaptop( "." ) Then
WScript.Echo "Desktop or server"
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.
' 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
On 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
If Err Then Err.Clear
On Error Goto 0
Open in new window
Get your personalized solution.
Please provide your email to receive a sample view!
*This site is protected by reCAPTCHA and the Google
Terms of Service apply.
Please enter a first name
Please enter a last name
8+ characters (letters, numbers, and a symbol)
Take hold of your future.