检测电脑硬件信息并保存文本到当前目录VBS脚本
-
- strComputer = "."
- Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\" & strComputer & "\root\cimv2")
-
- '主板
- Set board = objWMIService.ExecQuery ("Select * from Win32_BaseBoard")
- For Each objItem in board
- board2 = board2 & objItem.Product & ", "
- Next
- board2 = "主板:" & left(board2,len(board2)-3)
-
- 'BIOS
- 'Set bios = objWMIService.ExecQuery ("Select * from Win32_BIOS")
- 'For Each objItem in bios
- ' bios2 = bios2 & objItem.Name & " (" & objItem.Version & ")" & ", "
- 'Next
- 'bios2="BIOS:" & left(bios2,len(bios2)-3)
-
- '处理器
- Set cpu = objWMIService.ExecQuery ("Select * from Win32_Processor")
- For Each objItem in cpu
- cpu2= cpu2 & objItem.Name & ", "
- Next
- cpu2="处理器:" & left(cpu2,len(cpu2)-3)
-
- '内存
- Set memory = objWMIService.ExecQuery ("Select * from Win32_PhysicalMemory")
- num=0
- For Each objItem in memory
- total=total+ objItem.Capacity/1048576
- num=num+1
- Next
- memory2="内存:" & total & "M (" & num & ")"
-
- '硬盘
- Set disk = objWMIService.ExecQuery ("Select * from Win32_DiskDrive")
- For Each objItem in disk
- disk2=disk2 & objItem.Model & " (" & round(objItem.Size/1000000000) & "G), "
- Next
- disk2 = "硬盘:" & left(disk2,len(disk2)-3)
-
- '显卡
- Set video = objWMIService.ExecQuery ("Select * from Win32_VideoController")
- For Each objItem in video
- video2 =video2 & objItem.Description & ", "
- Next
- video2="显卡:" & left(video2,len(video2)-3)
-
- '声卡
- Set sound = objWMIService.ExecQuery ("Select * from Win32_SoundDevice")
- For Each objItem in sound
- sound2 = sound2 & objItem.Name & ", "
- Next
- sound2 = "声卡:" & left(sound2,len(sound2)-3)
-
- '网卡
- Set lan = objWMIService.ExecQuery ("Select * from Win32_NetworkAdapter")
- For Each objItem in lan
- if left(objItem.NetConnectionID,4)="本地连接" then
- lan2 = lan2 & objItem.Name & "(MAC:" & objItem.MacAddress & ")" & ", "
- end if
- Next
- lan2 = "网卡:" & left(lan2,len(lan2)-3)
-
- '光驱
- Set cdrom = objWMIService.ExecQuery ("Select * from Win32_CDROMDrive")
- For Each objItem in cdrom
- cdrom2=cdrom2 & objItem.Name & ", "
- Next
- cdrom2="光驱:" & left(cdrom2,len(cdrom2)-3)
-
- '电脑名
- Set computername = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
- For Each objItem in computername
- computername2 = objItem.Name
- Next
-
- '电脑型号
- 'Set computerModel = objWMIService.ExecQuery ("Select * from Win32_ComputerSystemProduct")
- 'For Each objItem in computerModel
- ' computerModel2 = objItem.vendor & objItem.name & "(" & objItem.IdentifyingNumber & ")"
- 'Next
- 'computerModel2 = "电脑型号:" & computerModel2
-
- '域及用户名
- 'set wshNetwork = WScript.CreateObject("WScript.Network")
- 'domain2 = "域:" & wshNetwork.UserDomain
- 'user2 = "用户名:" & wshNetwork.UserName
-
- '操作系统
- 'Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\cimv2")
- 'Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
- 'For Each objItem in colItems
- ' strOSVersion = objItem.Version
- 'Next
- 'select case strOSversion
- 'case "5.2.3790"
- ' System2 = "操作系统: Windows Server 2003"
- 'case "5.0.2195"
- ' System2 = "操作系统: Windows 2000"
- 'case "5.1.2600"
- 'System2 = "操作系统: Windows XP"
- 'case "6.0.6001"
- ' System2 = "操作系统: windows vista"
- 'case else
- ' System2 = "操作系统: i don't know"
- 'end select
-
- '建目录
- Set fso = CreateObject("Scripting.FileSystemObject")
-
- filename= computername2 & ".txt"
-
- '信息汇总
- out=computerModel2 & vbcrlf & _
- board2 & vbcrlf & _
- bios2 & vbcrlf & _
- cpu2 & vbcrlf & _
- memory2 & vbcrlf & _
- disk2 & vbcrlf & _
- video2 & vbcrlf & _
- sound2 & vbcrlf & _
- lan2 & vbcrlf & _
- cdrom2 & vbcrlf & _
- domain2 & vbcrlf & _
- user2 & vbcrlf & _
- System2
-
- '写到文件,如要写到多个地方,在下面按格式添加,不要的可以删除或用 ' 注释掉
- '---------写到当前目录
- filename= computername2 & ".txt"
- Set f1 = fso.CreateTextFile(filename)
- 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 |