UDF Computer info


SUBMITTED BY: Guest

DATE: May 29, 2013, 7:12 a.m.

FORMAT: Text only

SIZE: 5.8 kB

HITS: 1020

  1. #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
  2. #AutoIt3Wrapper_Icon=Info 3.ico
  3. #AutoIt3Wrapper_Res_Comment=Displays Service tag, computer name and model
  4. #AutoIt3Wrapper_Res_Fileversion=0.0.0.1
  5. #AutoIt3Wrapper_Res_LegalCopyright=GreenCan
  6. #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
  7. #include <Misc.au3>
  8. #cs
  9. Get some collection of information to help user open a ticket at the service desk
  10. User ID: Login Name of User
  11. Model: Model of PC
  12. Service Tag: Service tag or serial number of the PC (Tested on Dell)
  13. Computer Name: Identification of the PC
  14. IP Address: All Network adaptors with IP address
  15. If not currently used mentions '(Disabled)' after the IP address
  16. WLan connection : xxx.xxx.xxx.xxx
  17. LAN Connection : xxx.xxx.xxx.xxx (Disabled)
  18. Putclip when done
  19. #ce
  20. Global Const $wbemFlagReturnImmediately = 0x10
  21. Global Const $wbemFlagForwardOnly = 0x20
  22. Local $colItems = "", $Output, $Disabled = False
  23. $Output &= "User ID: " & @TAB & @UserName & @CRLF & @CRLF
  24. $objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
  25. $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", _
  26. $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
  27. If IsObj($colItems) then
  28. For $objItem In $colItems
  29. $Output &= "Model: " & @TAB & @TAB & $objItem.Name & @CRLF
  30. $Output &= "Service Tag: " & @TAB & $objItem.IdentifyingNumber & @CRLF
  31. $Output &= "Computer Name: " & @TAB & @ComputerName & @CRLF
  32. Next
  33. Local $Active_Adaptors = GetWMI(2)
  34. If @error = 2 Then $Disabled = True
  35. Local $i = 0, $NetworkCard, $Description, $ServiceName, $ServiceNameKeyValue
  36. While True
  37. $i += 1
  38. $NetworkCard = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards", $i)
  39. If @error <> 0 Then ExitLoop
  40. $Description = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\" & $NetworkCard , "Description")
  41. $ServiceName = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\" & $NetworkCard , "ServiceName")
  42. $ServiceNameKeyValue = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & $ServiceName , "DhcpIPAddress")
  43. ; check if network adaptor, otherwise skip
  44. If StringInStr($Active_Adaptors , $Description ) > 0 Then
  45. ; make it end-user readable
  46. $Output &= "IP Address: " & @TAB & _Iif(StringInStr($Description, "WLAN") > 0,"WLan connection", "LAN Connection ") & _
  47. " : " & $ServiceNameKeyValue & _Iif(StringInStr($Active_Adaptors , $Description & " (Disabled)")> 0, " (Disabled)", "") & @CRLF
  48. EndIf
  49. WEnd
  50. ; if all adaptors are disabled
  51. If $Disabled Then
  52. $Output &= "IP Address: " & @TAB & "All network adaptors are disabled"
  53. EndIf
  54. ClipPut($Output)
  55. Msgbox(0,"Computer Info",$Output & @CRLF & @CRLF & "For selfticketing purpose, the information has been copied to your clipboard." & @CRLF & "You can now paste it into your ticket")
  56. Else
  57. Msgbox(48,"Computer Info","No WMI Objects Found for class: " & "Win32_ComputerSystemProduct" )
  58. Endif
  59. Exit
  60. Func GetWMI($Status = 0)
  61. ; $Status = 0 ==> enabled
  62. ; $Status = 1 ==> disabled
  63. ; $Status = 2 ==> Both
  64. Local $Active_Adaptors, $Disabled_Adaptors, $_Adaptors, $colItems
  65. If $Status = 0 Then
  66. $colItems = $objWMIService.ExecQuery("SELECT Description FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True", "WQL", 0x00).Count
  67. If $colItems > 0 Then
  68. $colItems = $objWMIService.ExecQuery("SELECT Description FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True", "WQL", 0x30)
  69. If IsObj($colItems) Then
  70. For $objItem In $colItems
  71. $Active_Adaptors &= $objItem.Description & @CRLF
  72. Next
  73. SetError(0)
  74. Return $Active_Adaptors
  75. Else
  76. Return SetError(1)
  77. EndIf
  78. Else
  79. Return SetError(2)
  80. EndIf
  81. ElseIf $Status = 1 Then
  82. $colItems = $objWMIService.ExecQuery("SELECT Description FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = False", "WQL", 0x00).Count
  83. If $colItems > 0 Then
  84. $colItems = $objWMIService.ExecQuery("SELECT Description FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = False", "WQL", 0x30)
  85. If IsObj($colItems) Then
  86. For $objItem In $colItems
  87. $Disabled_Adaptors &= $objItem.Description & " (Disabled)" & @CRLF
  88. Next
  89. SetError(0)
  90. Return $Disabled_Adaptors
  91. Else
  92. Return SetError(1)
  93. EndIf
  94. Else
  95. Return SetError(2)
  96. EndIf
  97. ElseIf $Status = 2 Then
  98. $colItems = $objWMIService.ExecQuery("SELECT Description, IPEnabled FROM Win32_NetworkAdapterConfiguration", "WQL", 0x00).Count
  99. If $colItems > 0 Then
  100. $colItems = $objWMIService.ExecQuery("SELECT Description, IPEnabled FROM Win32_NetworkAdapterConfiguration", "WQL", 0x30)
  101. If IsObj($colItems) Then
  102. For $objItem In $colItems
  103. $_Adaptors &= $objItem.Description & _iif($objItem.IPEnabled = True,""," (Disabled)") & @CRLF
  104. ConsoleWrite(@ScriptLineNumber & " " & $objItem.Description & " " & _iif($objItem.IPEnabled = True,""," (Disabled)") & @CRLF)
  105. Next
  106. SetError(0)
  107. Return $_Adaptors
  108. Else
  109. Return SetError(1)
  110. EndIf
  111. Else
  112. Return SetError(2)
  113. EndIf
  114. EndIf
  115. EndFunc

comments powered by Disqus