Go Premium for a chance to win a PS4. Enter to Win
' 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
Public Function IsLaptop() As Boolean
Dim obj As Object
Dim result as Boolean = False
Set obj = GetObject("winmgmts://./root/cimv2").InstancesOf("Win32_Battery")
For Each battery In obj
result = True
Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.
One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.