+ Reply to Thread
Results 1 to 2 of 2

Thread: Check if pc is laptop or desktop

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    13

    Check if pc is laptop or desktop

    I wanted to perform a simple check if the current pc is laptop or desktop , actually i tried to figure it out , but how to know if it desktop or laptop ?

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    16
    Well , you do not need a certain function to check if it is a laptop computer or desktop computer , but i figured out a way to check that , simply i`ll check if the current pc has a battery module or not , because laptops has a battery component automatically integrated into operating system , smart huh ?
    Anyway here is the code to check that :
    Code:
    If IsLaptop( "." ) Then
         WScript.Echo "Laptop"
     Else
         WScript.Echo "Desktop computer"
     End If
    
     Function IsLaptop( myComputer )
    
         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
         Next
         If Err Then Err.Clear
         On Error Goto 0
     End Function

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts