Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for islaptop.kix

(view source code of islaptop.kix as plain text)

  1. ; Online help requested?
  2. If $help
  3. 	Syntax
  4. EndIf
  5.  
  6. ; Connect to computer's WMI service
  7. $objWMIService = GetObject( "winmgmts://./root/cimv2" )
  8. ; Display error number and description if applicable
  9. If @ERROR
  10. 	ShowError()
  11. EndIf
  12.  
  13. ; Get chassis object
  14. $colChassis = $objWMIService.ExecQuery( "Select * from Win32_SystemEnclosure", , 16 )
  15. ; Display error number and description if applicable
  16. If @ERROR
  17. 	ShowError()
  18. EndIf
  19.  
  20. ; Following code based on Guy Thomas' CHASSIS script
  21. ; http://computerperformance.co.uk/
  22. ; Remove statements if you want to check for more specific
  23. ; laptop type (see comment lines after each CASE statement)
  24. For Each $objChassis in $colChassis
  25. 	For Each $objItem in $objChassis.ChassisTypes
  26. 		Select
  27. 			Case $ObjItem =  8
  28. 				; Portable
  29. 				$IsLaptop = 1
  30. 			Case $ObjItem =  9
  31. 				; Laptop
  32. 				$IsLaptop = 1
  33. 			Case $ObjItem = 10
  34. 				; Notebook
  35. 				$IsLaptop = 1
  36. 			Case $ObjItem = 11
  37. 				; Hand Held
  38. 				$IsLaptop = 1
  39. 			Case $ObjItem = 12
  40. 				; Docking Station
  41. 				$IsLaptop = 1
  42. 			Case $ObjItem = 14
  43. 				; Sub Notebook
  44. 				$IsLaptop = 1
  45. 			Case 1
  46. 				$IsLaptop = 0
  47. 		EndSelect
  48. 	Next
  49. Next
  50.  
  51. ; Done
  52. If $IsLaptop
  53. 	"This computer is a laptop"
  54. Else
  55. 	"This computer is NOT a laptop"
  56. EndIf
  57. ; Return code
  58. Quit $IsLaptop
  59.  
  60.  
  61. Function ShowError()
  62. 	? "Error # @ERROR"
  63. 	?
  64. 	Syntax
  65. EndFunction
  66.  
  67.  
  68. Function Syntax()
  69. 	? "IsLaptop.kix,  Version 1.00"
  70. 	? "Check if a computer is a laptop"
  71. 	?
  72. 	? "Usage   :  KIX32  ISLAPTOP.KIX  [ $$help=1 ]"
  73. 	?
  74. 	? "Returns :  Errorlevel 2 after help screen, 1 on laptops, otherwise 0"
  75. 	?
  76. 	? "Notes   :  Based on Guy Thomas' CHASSIS.VBS (http://computerperformance.co.uk/)"
  77. 	? "           This script requires Windows 2000 or later and KiXtart 4.00 or later"
  78. 	?
  79. 	? "Written by Rob van der Woude"
  80. 	? "http://www.robvanderwoude.com"
  81. 	?
  82. 	; Abort with return code 1
  83. 	Quit 2
  84. EndFunction
  85.  
  86.  

page last modified: 2024-02-26; loaded in 0.0195 seconds