Board logo

标题: [转贴] VBS脚本获取远程计算机硬件信息 [打印本页]

作者: VBScript    时间: 2012-4-7 22:18     标题: VBS脚本获取远程计算机硬件信息

  1. 'on error resume next
  2. Dim WMI
  3. Dim sAns
  4. Dim Computer
  5. strComputer = InputBox("Enter Full Device Name", "Getting your Infos")
  6. '-------------------------------------------------------------------
  7. Set WMI = GetObject("WinMgmts:\\" & strComputer)
  8. Set objs = WMI.InstancesOf("Win32_Computersystem")
  9. for Each obj In objs
  10.   model = obj.Model
  11.   memory = obj.totalphysicalmemory
  12.   USER = obj.UserName
  13.   Computer = obj.Name
  14.   domain = obj.domain
  15. Next
  16. if memory > 1024 then
  17. memory=memory/1024
  18. memoryunit="KB"
  19. end if
  20. if memory > 1024 then
  21. memory=memory/1024
  22. memoryunit="MB"
  23. end if
  24. 'if memory > 1024 then
  25. ' memory=memory/1024
  26. ' memoryunit="GB"
  27. 'end if
  28. Set objs = WMI.InstancesOf("Win32_TimeZone")
  29. for Each obj In objs
  30.   TZ = obj.StandardName
  31. Next
  32. Set objs = WMI.InstancesOf("Win32_BIOS")
  33. for Each obj In objs
  34.   MBSerialNumber = obj.SerialNumber
  35.   BIOSVERSION = obj.SMBIOSBIOSVersion
  36. Next
  37. Set objs = WMI.InstancesOf("Win32_NetworkAdapterConfiguration")
  38. for Each obj In objs
  39. if obj.MACAddress<>"" then MACADDR = obj.MACAddress
  40. next
  41. ComputerName=Computer
  42.     Dim objWMIService,colItems,objItem,objAddress
  43.     Set objWMIService = GetObject("winmgmts:\\" & ComputerName & "\root\cimv2")
  44.     Set colItems = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
  45.     For Each objItem in colItems
  46.         For Each objAddress in objItem.IPAddress
  47.             If objAddress <> "" then
  48.                 GetIP = objAddress
  49.             End If
  50.         Next
  51.     Next
  52. Set objs = WMI.InstancesOf("Win32_DiskDrive")
  53. for Each obj In objs
  54.   HDDSize = obj.Size
  55. Next
  56. if HDDSize &gt; 1024 then
  57. HDDSize=HDDSize/1024
  58. HDDSizeunit="KB"
  59. end if
  60. if HDDSize &gt; 1024 then
  61. HDDSize=HDDSize/1024
  62. HDDSizeunit="MB"
  63. end if
  64. if HDDSize &gt; 1024 then
  65. HDDSize=HDDSize/1024
  66. HDDSizeunit="GB"
  67. end if
  68. Set objs = WMI.InstancesOf("Win32_PnPEntity")
  69. for Each obj In objs
  70.   if (obj.classguid = "{4D36E96E-E325-11CE-BFC1-08002BE10318}") then Monitor = mid(obj.DeviceID,9,instr(mid(obj.DeviceID,9),"\")-1)
  71.   if (left(obj.DeviceID,7) = "LPTENUM" AND obj.Description<>"Printer Port Logical Interface") then Printer = obj.Name
  72. Next
  73. Dim oADSystemInfo
  74. Dim strUserDN
  75. Dim objUser
  76. Set oADSystemInfo = CreateObject("ADSystemInfo")
  77. strUserDN = Replace(oADSystemInfo.UserName,"/","\/")
  78. Set objUser = GetObject("LDAP://" & strUserDN)
  79. strUserDisplayName = objUser.DisplayName   '得域账户显示名
  80. strUserMail= objUser.mail
  81. strUserAdsPath = objUser.AdsPath
  82. strUserGroups = objUser.memberOf
  83. for each usergroup in strUserGroups
  84. wscript.echo "UserGroups = " & usergroup
  85. next
  86. wscript.echo  strComputer & vbcrlf & _
  87. "Model = " & model & vbcrlf & _
  88.   "Serial = " & MBSerialNumber & vbcrlf & _
  89. "Bios Version = " & BIOSVERSION & vbcrlf & _
  90. "Memory = " & formatnumber(memory,0) & " " & memoryunit & vbcrlf & _
  91. "HDD Size = " & formatnumber(HDDSize,0) & " " & HDDSizeunit & vbcrlf & _
  92. "MAC Address = " & MACADDR & vbcrlf & _
  93. "Monitor = " & Monitor & vbcrlf & _
  94. "Printer = " & Printer & vbcrlf & _
  95. "TimeZone = " & TZ & vbcrlf & _
  96. "UserName = " & USER & vbcrlf & _
  97. "ComputerName = " & Computer & vbcrlf & _
  98. "domainName = " & domain & vbcrlf & _
  99. "IP = " & GetIP & vbcrlf & _
  100. "UserDisplayName = " & strUserDisplayName & vbcrlf & _
  101.   "UserMail= " & strUserMail & vbcrlf & _
  102.   "UserAdsPath = " & strUserAdsPath & vbcrlf
复制代码


http://lzy821218.blog.51cto.com/209800/273530




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2