效果图:

直接上源码了

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.12.0
Author: Qiulp

Script Function:
Template AutoIt script.

#ce ----------------------------------------------------------------------------
#include <file.au3>
#include <array.au3>

#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <ListviewConstants.au3>

Local $fp_PCInfo = @ScriptDir & "\PCInfo.txt"
Local $strPCInfoFormat = "csv"

If FileExists($fp_PCInfo) Then
FileDelete($fp_PCInfo)
EndIf

Local $strNicConfig = "wmic nicconfig list brief /format:" & $strPCInfoFormat & " >>" & $fp_PCInfo
Local $strOS = "wmic OS list brief /format:" & $strPCInfoFormat & " >>" & $fp_PCInfo
Local $strBOIS = "wmic bios list brief /format:" & $strPCInfoFormat & " >>" & $fp_PCInfo
Local $strMemorychip = "wmic memorychip get manufacturer, PartNumber,SerialNumber,Capacity,DeviceLocator,MemoryType,Name,TotalWidth /format:" & $strPCInfoFormat & " >>" & $fp_PCInfo
Local $strCPU = "wmic CPU list brief /format:" & $strPCInfoFormat & " >>" & $fp_PCInfo
Local $strDiskdrive = "wmic diskdrive list brief /format:" & $strPCInfoFormat & " >>" & $fp_PCInfo
Local $strSoundDev = "wmic SoundDev list brief /format:" & $strPCInfoFormat & " >>" & $fp_PCInfo
Local $strBaseboard = "wmic baseboard list brief /format:" & $strPCInfoFormat & " >>" & $fp_PCInfo

Local $aPCAlias[8][2]
$aPCAlias[0][0] = "OS"
$aPCAlias[0][1] = $strOS
$aPCAlias[1][0] = "BIOS"
$aPCAlias[1][1] = $strBOIS
$aPCAlias[2][0] = "Baseboard"
$aPCAlias[2][1] = $strBaseboard
$aPCAlias[3][0] = "CPU"
$aPCAlias[3][1] = $strCPU
$aPCAlias[4][0] = "Memory"
$aPCAlias[4][1] = $strMemorychip
$aPCAlias[5][0] = "Diskdrive"
$aPCAlias[5][1] = $strDiskdrive
$aPCAlias[6][0] = "Sound"
$aPCAlias[6][1] = $strSoundDev
$aPCAlias[7][0] = "Net"
$aPCAlias[7][1] = $strNicConfig

_WritePCInfo()
Local $aArray = FileReadToArray($fp_PCInfo)
Local $iRowIndex = 1

If UBound($aArray) <= 8 Then
MsgBox(0, "", "Can not collect PC information.")
Exit
EndIf

#Region ### START Koda GUI section ### Form=
$formPC = GUICreate("PC information collection tool", 1000, 437, 192, 124)
$tabType = GUICtrlCreateTab(10, 10, 982, 420)
GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM+$GUI_DOCKHCENTER+$GUI_DOCKVCENTER+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)

Local $lvHandle[UBound($aPCAlias)]
Local $strCurrentString, $aTemp
For $i = 0 To UBound($aPCAlias) - 1
GUICtrlCreateTabItem($aPCAlias[$i][0])

$strCurrentString = $aArray[$iRowIndex]
$lvHandle[$i] = GUICtrlCreateListView(StringReplace($strCurrentString, ",", "|"), 16, 35, 970, 390, bitor($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
GUISetBkColor(0x00E0FFFF)
$iRowIndex += 1

While $aArray[$iRowIndex] <> ""
$strCurrentString = $aArray[$iRowIndex]
If $aPCAlias[$i][0] == "Memory" Then
$aTemp = StringSplit($strCurrentString, ",", 2)
$aTemp[1] = _SwitchToMb($aTemp[1])
$strCurrentString = _ArrayToString($aTemp, ",")
EndIf

If $aPCAlias[$i][0] == "Diskdrive" Then
$aTemp = StringSplit($strCurrentString, ",", 2)
$aTemp[5] = _SwitchToMb($aTemp[5])
$strCurrentString = _ArrayToString($aTemp, ",")
EndIf

GUICtrlCreateListViewItem(StringReplace($strCurrentString, ",", "|"), $lvHandle[$i])
$iRowIndex += 1
If $iRowIndex = UBound($aArray) Then ExitLoop
WEnd

$iRowIndex += 1 ;jump the empty row
Next

GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd

Func _SwitchToMb($strNumber)
Return String(int(Number($strNumber) / (1024 * 1024))) & " Mb"
EndFunc

Func _WritePCInfo()
For $i = 0 To UBound($aPCAlias) - 1
;ConsoleWrite($aPCAlias[$i][1] & @CRLF)
RunWait(@ComSpec & " /c " & $aPCAlias[$i][1], @ScriptDir, @SW_HIDE)
_AppendLineToFile($fp_PCInfo, @CRLF)
Next
EndFunc

Func _AppendLineToFile($strFilepath, $strContent)
Local $hFileOpen = FileOpen($strFilepath, $FO_APPEND)
If $hFileOpen = -1 Then
MsgBox(0, "", "An error occurred when reading the file.")
Return False
EndIf

; Write data to the file using the handle returned by FileOpen.
FileWriteLine($hFileOpen, $strContent)

; Close the handle returned by FileOpen.
FileClose($hFileOpen)
EndFunc

autoit使用WMIC获取硬件信息的更多相关文章

  1. WMI 获取硬件信息的封装函数与获取联想台式机的出厂编号方法

    原文:WMI 获取硬件信息的封装函数与获取联想台式机的出厂编号方法 今天玩了一把WMI,查询了一下电脑的硬件信息,感觉很多代码都是可以提取出来的,就自己把那些公共部分提出出来,以后如果要获取 某部分的 ...

  2. linux下dmidecode命令获取硬件信息

    linux下dmidecode命令获取硬件信息 2 A+ 所属分类:Linux 运维工具 dmidecode在 Linux 系统下获取有关硬件方面的信息.dmidecode 遵循 SMBIOS/DMI ...

  3. C#获取硬件信息

    //硬件信息 public class GF_Hardware { /// <summary> /// cpu序列号 /// </summary> /// <return ...

  4. ansible facts 获取硬件信息

    facts 指的是 ansible_facts 变量,ansible 中使用 setup 模块来获取,包含系统的大部分基础硬件信息, [root@10_1_162_39 host_vars]# ll ...

  5. 获取硬件信息的delphi源码CPUID、操作系统、Mac物理地址、计算机名称、IP地址、用户名

    {-----------------------------------------------------------------------------作者:sushengmiyan 2013.0 ...

  6. Web网站中利用JavaScript中ActiveXObject对象获取硬件信息(显示器数量、分辨率)从而进行单双屏跳转

    前言:最近这两天工作上,要实现一个功能,在好友阿聪的帮助下,算是比较好的解决了这个需求. B/S的Web网站,需要实现点击按钮时,根据客户端连接的显示屏(监视器)数量进行,单双屏跳转显示新页面. 由于 ...

  7. Powershell获取硬件信息

    1.获取系统的BIOS的信息: Get-WMIObject -Class Win32_BIOS 2.获取内存信息: Get-WMIObject -Class Win32_PhysicalMemory ...

  8. C#通过WMI获取硬件信息

    有时候需要得到硬件信息绑定用户登录 代码如下: private string GetProcessSerialNumber() { try { ManagementObjectCollection P ...

  9. 使用dmidecode在Linux下获取硬件信息

    dmidecode命令可以让你在Linux系统下获取有关硬件方面的信息.dmidecode的作用是将DMI数据库中的信息解码,以可读的文本方式显示.由于DMI信息可以人为修改,因此里面的信息不一定是系 ...

随机推荐

  1. malloc分配的内存空间是连续的吗

    1.linux内核管理内存空间的分配,所有程序对内存空间的申请和其他操作,最终都会交给内核来管理. 2.linux实现的是“虚拟内存系统”,对用户而言,所有内存都是虚拟的,也就是说程序并不是直接运行在 ...

  2. JS正则截取两个字符串之间的字符串

    match方法 var str = "iid0000ffr"; var substr = str.match(/id(\S*)ff/); console.log(substr) 返 ...

  3. Who is using Asio?

    https://think-async.com/Asio/WhoIsUsingAsio

  4. Shell编程之--“grep-awk-sed” 基础用法汇总-菜鸟入门级

  5. 关于lemon oa的数据库

    lemonOA的数据库默认用的是hsqldb,这个数据库还是第一次听说,暂且不论. 也就说Lemon OA默认使用HSQLDB数据库,是嵌入式的数据库不需要单独安装. lemon-1.4.0\weba ...

  6. HTML JavaScripts

    JavaScript JavaScript是一门编程语言,浏览器内置了JavaScript语言的解释器,所以在浏览器上按照JavaScript语言的规则编写相应代码之,浏览器可以解释并做出相应的处理. ...

  7. C#Random函数在循环中每次获取一样的值

    首先需要了解一点Random函数的随机生成是和当前时间有关系,如果在短时间生成随机数,就会导致随机数生成出来是相同的. 不过我们可以在每次随机时指定一个Seed种子值,这样在循环里就可以每次获取不一样 ...

  8. SOAOffice和iWebOffice、NTKO的比较及其优势(转)

    http://www.cnblogs.com/liping13599168/articles/1681465.html SOAOffice和iWebOffice.NTKO的比较及其优势 近年来,市场上 ...

  9. Netty的TCP粘包/拆包(源码二)

    假设客户端分别发送了两个数据包D1和D2给服务器,由于服务器端一次读取到的字节数是不确定的,所以可能发生四种情况: 1.服务端分两次读取到了两个独立的数据包,分别是D1和D2,没有粘包和拆包. 2.服 ...

  10. OAF_文件系列9_实现OAF解析Excel并读取至数据库JXL

    ddd puroder. webui. poLineExcelImport.java