Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for hardware.kix

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

  1. ; Check KiXtart version
  2. $KixMajorVer = SubStr( @Kix, 1, InStr( @Kix, "." ) - 1 )
  3. If $KixMajorVer < 4
  4. 	GoTo Syntax
  5. EndIf
  6.  
  7. ; Header line for screen output
  8. ? "Hardware summary for @WKSTA:"
  9. ?
  10.  
  11. ; Connect to specified computer
  12. $objWMIService = GetObject( "winmgmts://./root/cimv2" )
  13. ; Display error number if applicable
  14. If @ERROR
  15. 	GoTo ShowError
  16. EndIf
  17.  
  18. ? "Processor(s)"
  19. ?
  20.  
  21. ; Query processor properties
  22. $colItems = $objWMIService.ExecQuery( "Select * from Win32_Processor", "WQL", 48 )
  23. ; Display error number if applicable
  24. If @ERROR
  25. 	GoTo ShowError
  26. EndIf
  27. ; Display results
  28. For Each $objItem in $colItems
  29. 	? "    Name:                    " + Trim( $objItem.Name )
  30. 	? "    Manufacturer:            " + $objItem.Manufacturer
  31. 	? "    Description:             " + $objItem.Description
  32. 	? "    Current Clock Speed:     " + $objItem.CurrentClockSpeed + " MHz"
  33. 	?
  34. Next
  35.  
  36. ? "Memory"
  37. ?
  38.  
  39. ; Query number of meory banks
  40. $colItems = $objWMIService.ExecQuery( "Select * from Win32_PhysicalMemoryArray", "WQL", 48 )
  41. ; Display error number if applicable
  42. If @ERROR
  43. 	GoTo ShowError
  44. EndIf
  45. ; Display results
  46. For Each $objItem In $colItems
  47. 	? "    Memory Banks:            " + $objItem.MemoryDevices
  48. Next
  49.  
  50. ; Query memory modules properties
  51. $cntMod = 0
  52. $strMod = ""
  53. $colItems = $objWMIService.ExecQuery( "Select * from Win32_PhysicalMemory", "WQL", 48 )
  54. For Each $objItem In $colItems
  55. 	$cntMod = $cntMod + 1
  56. 	$strCap = ( Val( $objItem.Capacity ) + 1023 ) / ( 1024 * 1024 )
  57. 	$strMod = $strMod + " + " + $strCap
  58. Next
  59. ? "    Memory Modules:          " + $cntMod + " (" + SubStr( $strMod, 4 ) + " MB)"
  60.  
  61. ; Query total memory
  62. $colItems = $objWMIService.ExecQuery( "Select * from Win32_LogicalMemoryConfiguration", "WQL", 48 )
  63. ; Display error number if applicable
  64. If @ERROR
  65. 	GoTo ShowError
  66. EndIf
  67. ; Display results
  68. For Each $objItem In $colItems
  69. 	? "    Total Physical Memory:   " + ( $objItem.TotalPhysicalMemory + 1023 ) / 1024 + " MB"
  70. 	?
  71. Next
  72.  
  73. ? "Harddisk(s)"
  74. ?
  75.  
  76. ; Query harddisk properties
  77. $colItems = $objWMIService.ExecQuery( "Select * from Win32_DiskDrive Where SCSITargetId >= 0", "WQL", 48 )
  78. ; Display error number if applicable
  79. If @ERROR
  80. 	GoTo ShowError
  81. EndIf
  82. ; Display results
  83. For Each $objItem in $colItems
  84. 	? "    Manufacturer:            " + $objItem.Manufacturer
  85. 	? "    Model:                   " + $objItem.Model
  86. 	; Some trickery to enable working with large numbers
  87. 	$Size  = $objItem.Size
  88. 	$LSize = Len( $Size )
  89. 	$MSize = SubStr( $Size, 1, $LSize - 3 )
  90. 	$Size  = ( 524288 + $MSize ) / 1048576
  91. 	? "    Size:                    $Size GB"
  92. 	?
  93. Next
  94.  
  95. ? "Video"
  96. ?
  97.  
  98. ; Query video adapter properties
  99. $colItems = $objWMIService.ExecQuery( "Select * from Win32_VideoController", , 48 )
  100. ; Display error number if applicable
  101. If @ERROR
  102. 	GoTo ShowError
  103. EndIf
  104. ; Display results
  105. For Each $objItem in $colItems
  106. 	? "    Name:                    " + $objItem.Name
  107. 	? "    Video Processor:         " + $objItem.VideoProcessor
  108. 	? "    Adapter RAM:             " + ( ( $objItem.AdapterRAM + 524288 ) / 1048576 ) + " MB"
  109. 	? "    Video Mode Description:  " + $objItem.VideoModeDescription
  110. 	?
  111. Next
  112.  
  113. ; Done
  114. Quit 0
  115.  
  116.  
  117. :ShowError
  118. ? "Error # @ERROR"
  119. ?
  120.  
  121. :Syntax
  122. ? "Hardware.kix,  Version 1.10"
  123. ? "Display a basic hardware summary for the local computer"
  124. ?
  125. ? "Usage:  KIX32  HARDWARE.KIX"
  126. ?
  127. ? "Written by Rob van der Woude"
  128. ? "http://www.robvanderwoude.com"
  129. ?
  130. ? "This script needs KiXtart version 4.* or later."
  131. ? "Your KiXtart version is @KIX."
  132. ?
  133. Quit 1
  134.  

page last modified: 2024-04-16; loaded in 0.0080 seconds