ac5474012 发表于 2021-8-12 11:10:50

【已解决】请问如何返回计算机配置?

本帖最后由 ac5474012 于 2021-8-12 12:42 编辑

cpu,内存,硬盘数量以及每块硬盘的容量。

ac5474012 发表于 2021-8-12 12:41:53

找到了

TrayTip("提示","开始登记电脑的信息!",100,1)
$objWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
$objItems = $objWMI.ExecQuery("SELECT * FROM Win32_SystemEnclosure")
For $ComputerSystem In $objItems
        If$ComputerSystem.SMBIOSAssetTag<>"" Then
        Global $AssetTag = $ComputerSystem.SMBIOSAssetTag
        Else
        $AssetTag = StringTrimLeft(@ComputerName,7)
        EndIf
Next
      $objItems = ""
   
;获取bios信息
    $objItems = $objWMI.ExecQuery("Select * from Win32_BIOS")
   
    For $objabc In $objItems
      Global $sn = $objabc.Caption
    Next
    $objItems = ""

;获取主板信息
$objItems = $objWMI.ExecQuery("SELECT * FROM Win32_BaseBoard")
For $objabc In $objItems
        Global $zhuban = $objabc.Product
Next
$objItems = ""
;获取显卡信息
$objItems = $objWMI.ExecQuery("Select * from Win32_VideoController")
For $objabc In $objItems
        Global $xianka = $objabc.Description
Next
$objItems = ""

;获取声卡
$objItems = $objWMI.ExecQuery("Select * from Win32_SoundDevice")
For $objabc In $objItems
        Global $shengka = $objabc.Description
Next
$objItems = ""

;获取网卡信息(只能有一张活动的网卡)
$objItems = $objWMI.ExecQuery("Select * from Win32_NetworkAdapter WHERE Netconnectionstatus = 2")
For $objabc In $objItems
        Global $wangka = $objabc.name
        Global $mac = $objabc.MACAddress
Next
$objItems = ""
;获取ip地址
$ip = @IPAddress1

;获取内存信息
$objItems = $objWMI.ExecQuery("Select * from Win32_ComputerSystem")
For $objabc In $objItems
        Global $neicun = Round($objabc.totalphysicalmemory / (1024 * 1024) & " Mb")
Next
$objItems = ""


;获取系统信息
$objItems = $objWMI.ExecQuery("Select * from Win32_operatingsystem")
    For $objabc In $objItems
    Global$xitong = $objabc.Caption
    Next
   $objItems = ""

      
;获取cpu型号
    $objItems = $objWMI.ExecQuery("Select * from Win32_processor")
    For $objabc In $objItems
      $cpu = $objabc.Name
    Next
    $objItems = ""

;获取硬盘大小
    $objItems = $objWMI.ExecQuery("Select * from Win32_diskdrive")
    $disk = ""
    For $objabc In $objItems
      If $disk = "" Then
    Global   $disk = Round($objabc.Size / 1073741824, 2)
      EndIf
    Next
    $objItems = ""

;获取计算机名字
    $objItems = $objWMI.ExecQuery("Select * from Win32_ComputerSystem")
    For $objabc In $objItems
      $ram = Round($objabc.totalphysicalmemory / 1073741824, 1)
        Global$username = @UserName ;当前登录的用户名
        Global   $hostname = @ComputerName
      Next
    $objItems = ""
       
;~         MsgBox(0,"",$hostname&@LF&$cpu&@LF&$sn&@LF&$zhuban&@LF&$xianka&@LF&$shengka&@LF&$wangka&@LF&$neicun&@LF&$xitong&@LF&$ip&@LF&$mac&@LF&$disk)
页: [1]
查看完整版本: 【已解决】请问如何返回计算机配置?