效果图:

直接上源码了

#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. fastjson解析json,model字段有顺序要求吗

    解决办法已经写到我的公众号,二维码在下面,欢迎关注,谢谢. 本人联系方式: 更多精彩分享,可关注我的微信公众号: 若想给予我分享更多知识的动力,请扫描下面的微信打赏二维码,谢谢!: 微信号:Weixi ...

  2. 『U3D学习』破坏神回忆图<二>技能系统

  3. JavaScript 介绍

          JavaScript一种直译式脚本语言,是一种动态类型.弱类型.基于原型的语言,内置支持类型.它的解释器被称为JavaScript引擎,为浏览器的一部分,广泛用于客户端的脚本语言,最早是在 ...

  4. 关于回溯与n个数的全排列

    今天要讲的题目是全排列的问题:有1.2.3.....n这样一个数列,要求输出其全排列. 那么,显然,这道题目非常之简单,用一个标志数组变量,标记数字的使用情况,然后根据它挑选数字即可.由于题目很简单, ...

  5. 【转】Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing

    最近在看Java,在编译写书上一个例子时,由于书上的代码只有一部分,于是就自己补了一个内部类.结果编译时出现:No enclosing instance of type E is accessible ...

  6. WPF-编程问题和解决

    1.wpf中点击button按钮后怎么让TextBlock显示button按钮的值? <TextBlock x:Name="CurProtext" Grid.Column=& ...

  7. SQL Server常用的性能诊断语句

    /* 常规服务器动态管理对象包括: dm_db_*:数据库和数据库对象 dm_exec_*:执行用户代码和关联的连接 dm_os_*:内存.锁定和时间安排 dm_tran_*:事务和隔离 dm_io_ ...

  8. [MySQL5.6 新特性] 全局事务标示符(GTID)

    GTID的全称为 global transaction identifier  , 可以翻译为全局事务标示符,GTID在原始master上的事务提交时被创建.GTID需要在全局的主-备拓扑结构中保持唯 ...

  9. 关于databinding的细节

    原文在此:http://www.codeproject.com/Articles/24656/A-Detailed-Data-Binding-Tutorial 完整译文在此:http://www.cn ...

  10. Mybatis与Hibernate的区别

    首先简单介绍下两者的概念: Hibernate :Hibernate 是当前最流行的ORM框架,对数据库结构提供了较为完整的封装. Mybatis:Mybatis同样也是非常流行的ORM框架,主要着力 ...