效果图:

直接上源码了

#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. POJ 3414 解题报告!

    原题: Pots Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 13227 Accepted: 5550 Special Jud ...

  2. js中toString和valueOf方法的区别

    toString 方法 返回对象的字符串表示形式. 语法:objectname.toString([radix]) objectname 必需.要为其搜索字符串表示形式的对象. radix 可选.为将 ...

  3. 【Cocos2d-x 3.x】 调度器Scheduler类源码分析

    非个人的全部理解,部分摘自cocos官网教程,感谢cocos官网. 在<CCScheduler.h>头文件中,定义了关于调度器的五个类:Timer,TimerTargetSelector, ...

  4. linux 添加基于weblogic的nodemanager的服务

    用nodemanager来添加weblogic服务启动. 1.新建一个server,命名为Server1,端口设置为7055,其他采用默认值. 2.新建一个Machine,命名为Machine1.配置 ...

  5. Oracle启动脚本,开机自启动设置

    #!/bin/sh # chkconfig: # description: Oracle auto start-stop script. # # Set ORA_HOME to be equivale ...

  6. html5高级

    Html5高级 项目回顾 Day 01 第三阶段知识体系: (1)AJAX异步请求 数据库.PHP.HTTP.原生AJAX.jQuery中的AJAX (2)HTML5高级特性 九大新特性 (3)Boo ...

  7. mybatis 与 缓存

    首先从配置文件说起,有个cacheEnabled的配置项,当设置为true时(默认就是true),Session就会用一个CachingExecutor来包装我们的Executor实例: public ...

  8. linux 几个控制流语句的格式例子(if语句)

    linux 几个控制流语句的格式例子:if 语句例子:#!/bin/sh a=10b=20 if [ $a == $b ]then echo "a is equal to b"el ...

  9. 大数据每日干货第四天(linux基础之一目录结构与常用命令)

           为了和qq空间同步,也写的第四天,前面几天明天会发布,本来打算把每天学的东西记录下来,通过朋友给的建议要发的话稍微系统化下,从大数据需要的linux基础,到离线数据分析包括hadoop. ...

  10. ecmobile中IOS版本中界面文字不显示的解决

    查找以下方法. - (BOOL)setCurrentLanguageName:(NSString *)name{        BeeLanguage * lang = [self findLangu ...