(view source code of islaptop.kix as plain text)
; Online help requested?
If $help
Syntax
EndIf
; Connect to computer's WMI service
$objWMIService = GetObject( "winmgmts://./root/cimv2" )
; Display error number and description if applicable
If @ERROR
ShowError()
EndIf
; Get chassis object
$colChassis = $objWMIService.ExecQuery( "Select * from Win32_SystemEnclosure", , 16 )
; Display error number and description if applicable
If @ERROR
ShowError()
EndIf
; Following code based on Guy Thomas' CHASSIS script
; http://computerperformance.co.uk/
; Remove statements if you want to check for more specific
; laptop type (see comment lines after each CASE statement)
For Each $objChassis in $colChassis
For Each $objItem in $objChassis.ChassisTypes
Select
Case $ObjItem = 8
; Portable
$IsLaptop = 1
Case $ObjItem = 9
; Laptop
$IsLaptop = 1
Case $ObjItem = 10
; Notebook
$IsLaptop = 1
Case $ObjItem = 11
; Hand Held
$IsLaptop = 1
Case $ObjItem = 12
; Docking Station
$IsLaptop = 1
Case $ObjItem = 14
; Sub Notebook
$IsLaptop = 1
Case 1
$IsLaptop = 0
EndSelect
Next
Next
; Done
If $IsLaptop
"This computer is a laptop"
Else
"This computer is NOT a laptop"
EndIf
; Return code
Quit $IsLaptop
Function ShowError()
? "Error # @ERROR"
?
Syntax
EndFunction
Function Syntax()
? "IsLaptop.kix, Version 1.00"
? "Check if a computer is a laptop"
?
? "Usage : KIX32 ISLAPTOP.KIX [ $$help=1 ]"
?
? "Returns : Errorlevel 2 after help screen, 1 on laptops, otherwise 0"
?
? "Notes : Based on Guy Thomas' CHASSIS.VBS (http://computerperformance.co.uk/)"
? " This script requires Windows 2000 or later and KiXtart 4.00 or later"
?
? "Written by Rob van der Woude"
? "http://www.robvanderwoude.com"
?
; Abort with return code 1
Quit 2
EndFunction
page last modified: 2024-04-16; loaded in 0.0054 seconds