Check if Notebook or PC?

Posted on 2009-07-03
Last Modified: 2012-05-07

How can I check in VB.NET if it is a PC or a Notebook?

Question by:Ruttensoft
  • 2

Expert Comment

ID: 24773803
Here you go.  If you need an action, add it below the echo for if/else.

Hope this helps.
' Shutdown.vbs

' Example VBScript to check if computer is laptop or workstation

' Author Lance Dobbs

' Version 1.1 - July 2009

' --------------------------------------

If IsLaptop( "." ) Then

    WScript.Echo "Laptop"


    WScript.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


    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

End Function 

Open in new window

LVL 55

Accepted Solution

Jaime Olivares earned 500 total points
ID: 24773896
Try with the following version:

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


  Return result

End Function

Open in new window


Expert Comment

ID: 24804072

Did you find a solution for you question?


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Internet Business Fax to Email Made Easy - With  eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

912 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now