AM电脑吧 - Win10精简版系统_Win11精简版_Win7旗舰版

Yes
查看: 9476|回复: 15
收起左侧

[其它] 检测电脑硬件信息并保存文本到当前目录VBS脚本

[复制链接]
ampc81

签到天数: 679 天

[LV.9]九级电脑高手

id 发表于 2011-05-18 18:13:23
检测电脑硬件信息并保存文本到当前目录VBS脚本


  1. strComputer = "."
  2. Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\" & strComputer & "\root\cimv2")

  3. '主板
  4. Set board = objWMIService.ExecQuery ("Select * from Win32_BaseBoard")
  5. For Each objItem in board
  6.     board2 = board2 & objItem.Product & ",  "
  7. Next
  8. board2 = "主板:" & left(board2,len(board2)-3)

  9. 'BIOS
  10. 'Set bios = objWMIService.ExecQuery ("Select * from Win32_BIOS")
  11. 'For Each objItem in bios
  12. '    bios2 = bios2 & objItem.Name & " (" & objItem.Version & ")" & ",  "
  13. 'Next
  14. 'bios2="BIOS:" & left(bios2,len(bios2)-3)

  15. '处理器
  16. Set cpu = objWMIService.ExecQuery ("Select * from Win32_Processor")
  17. For Each objItem in cpu
  18.     cpu2= cpu2 & objItem.Name & ",  "
  19. Next
  20. cpu2="处理器:" & left(cpu2,len(cpu2)-3)

  21. '内存
  22. Set memory = objWMIService.ExecQuery ("Select * from Win32_PhysicalMemory")
  23. num=0
  24. For Each objItem in memory
  25.     total=total+ objItem.Capacity/1048576
  26.     num=num+1
  27. Next
  28. memory2="内存:" & total & "M (" & num & ")"

  29. '硬盘
  30. Set disk = objWMIService.ExecQuery ("Select * from Win32_DiskDrive")
  31. For Each objItem in disk
  32.     disk2=disk2 & objItem.Model & " (" & round(objItem.Size/1000000000) & "G),  "
  33. Next
  34. disk2 = "硬盘:" & left(disk2,len(disk2)-3)

  35. '显卡
  36. Set video = objWMIService.ExecQuery ("Select * from Win32_VideoController")
  37. For Each objItem in video
  38.     video2 =video2 & objItem.Description & ",  "
  39. Next
  40. video2="显卡:" & left(video2,len(video2)-3)

  41. '声卡
  42. Set sound = objWMIService.ExecQuery ("Select * from Win32_SoundDevice")
  43. For Each objItem in sound
  44.     sound2 = sound2 & objItem.Name & ",  "
  45. Next
  46. sound2 = "声卡:" & left(sound2,len(sound2)-3)


  47. '网卡
  48. Set lan = objWMIService.ExecQuery ("Select * from Win32_NetworkAdapter")
  49. For Each objItem in lan
  50.   if left(objItem.NetConnectionID,4)="本地连接" then
  51.     lan2 = lan2 & objItem.Name & "(MAC:" & objItem.MacAddress & ")" & ",  "
  52.   end if
  53. Next
  54. lan2 = "网卡:" & left(lan2,len(lan2)-3)

  55. '光驱
  56. Set cdrom = objWMIService.ExecQuery ("Select * from Win32_CDROMDrive")
  57. For Each objItem in cdrom
  58.     cdrom2=cdrom2 & objItem.Name & ",  "
  59. Next
  60. cdrom2="光驱:" & left(cdrom2,len(cdrom2)-3)

  61. '电脑名
  62. Set computername = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
  63. For Each objItem in computername
  64.     computername2 = objItem.Name
  65. Next

  66. '电脑型号
  67. 'Set computerModel = objWMIService.ExecQuery ("Select * from Win32_ComputerSystemProduct")
  68. 'For Each objItem in computerModel
  69. '   computerModel2 = objItem.vendor & objItem.name & "(" & objItem.IdentifyingNumber & ")"
  70. 'Next
  71. 'computerModel2 = "电脑型号:" & computerModel2


  72. '域及用户名
  73. 'set wshNetwork = WScript.CreateObject("WScript.Network")
  74. 'domain2 = "域:" & wshNetwork.UserDomain
  75. 'user2 = "用户名:" & wshNetwork.UserName

  76. '操作系统
  77. 'Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\cimv2")
  78. 'Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
  79. 'For Each objItem in colItems
  80. '        strOSVersion = objItem.Version
  81. 'Next
  82. 'select case strOSversion
  83. 'case "5.2.3790"
  84. '   System2 = "操作系统: Windows Server 2003"
  85. 'case "5.0.2195"
  86. '     System2 = "操作系统: Windows 2000"
  87. 'case "5.1.2600"
  88. 'System2 = "操作系统: Windows XP"
  89. 'case "6.0.6001"
  90. '    System2 = "操作系统: windows vista"
  91. 'case else
  92. '    System2 = "操作系统: i don't know"
  93. 'end select

  94. '建目录
  95. Set fso = CreateObject("Scripting.FileSystemObject")

  96. filename= computername2 & ".txt"

  97. '信息汇总
  98. out=computerModel2 & vbcrlf & _
  99.     board2 & vbcrlf & _
  100.     bios2 & vbcrlf & _
  101.     cpu2 & vbcrlf & _
  102.     memory2 & vbcrlf & _
  103.     disk2 & vbcrlf & _
  104.     video2 & vbcrlf & _
  105.     sound2 & vbcrlf & _
  106.     lan2 & vbcrlf & _
  107.     cdrom2 & vbcrlf & _
  108.     domain2 & vbcrlf & _
  109.     user2 & vbcrlf & _
  110.     System2

  111. '写到文件,如要写到多个地方,在下面按格式添加,不要的可以删除或用 ' 注释掉
  112. '---------写到当前目录
  113. filename= computername2 & ".txt"
  114. Set f1 = fso.CreateTextFile(filename)
  115. f1.WriteLine(out)
复制代码



主板:C.N61G

处理器:AMD Athlon(tm) 64 X2 Dual Core Processor 4000+
内存:3072M (2)
硬盘:Hitachi HDS721616PLA SCSI Disk Device (160G),  ST350041 8AS SCSI Disk Device (500G)
显卡:NVIDIA GeForce 6100 nForce 405 (Microsoft Corporation - WDDM)
声卡:Realtek High Definition Audio
网卡:Realtek RTL8139/810x Family Fast Ethernet NIC(MAC:00:F0:CF:86:F4:65)
光驱:PHILIPS SPD2417T ATA Device

本文地址: https://www.ampc8.com/thread-658-1-1.html
上一篇:解析电脑提示“没有找到COMRes.dll”的故障
下一篇:目前装机4大坑骗原因,装机请远离!
回复

举报

ampc823649

签到天数: 3 天

[LV.2]二兆带宽

id zpmc123 发表于 2015-07-19 12:31:48 手机发帖
阿木很牛很牛啊
回复

举报

ampc812927

签到天数: 2 天

[LV.1]一个记事本

id yuxuan 发表于 2013-03-17 22:04:58
看看脚本,支持阿木
回复

举报

头像被屏蔽

签到天数: 9 天

[LV.3]三流显示器

id jsgh1983 发表于 2012-08-21 19:52:08
看看学习学习!不知道是用什么方法获取的!谢谢分享!
回复

举报

ampc88690

签到: Lazy

id zqqdnb 发表于 2012-07-20 13:14:10
找了半天,终于有收获了
回复

举报

ampc86313

签到天数: 2 天

[LV.1]一个记事本

id 一嗰亼的笹堺 发表于 2012-02-21 15:04:31
vbs的代码就先不看了,需要时再看
回复

举报

ampc8177

签到天数: 22 天

[LV.4]四枚内存条

id 聆听雨的心 发表于 2012-02-03 18:53:25
试试看先谢谢分享
回复

举报

ampc85779

签到天数: 1 天

[LV.1]一个记事本

id |▍、ー种、未完 发表于 2012-02-03 12:27:31
需要时再看
回复

举报

ampc8471

签到天数: 21 天

[LV.4]四枚内存条

id ahzsm 发表于 2011-05-22 18:57:45
看看,学习才能进步
回复

举报

ampc861

签到天数: 124 天

[LV.7]七个CPU

id 大海深处 发表于 2011-05-22 08:59:26
我的也是老爷机了 下了看看
回复

举报

您需要登录后才可以回帖 登录 | 验证注册

Powered by AMpc8.Com (晋ICP备13003365号ghs 晋公网安备 14090202000112号 |GMT+8, 2025/5/1 03:57 | A
快速回复 返回顶部 返回列表