Win10下通过WMIC获取内存配置和使用信息

您所在的位置:网站首页 configuredclockspeed是什么 Win10下通过WMIC获取内存配置和使用信息

Win10下通过WMIC获取内存配置和使用信息

2024-07-12 14:27:12| 来源: 网络整理| 查看: 265

基本原理,通过WMIC,获取memorychip和memphysical相关信息

 

例子1,使用MEMORYCHIP获取安装的memory信息,按bank区分

D:\>wmic MEMORYCHIP get Banklabel,DeviceLocator,MemoryType,TypeDetail,speedBankLabel DeviceLocator MemoryType Speed TypeDetailBANK 0 ChannelA-DIMM0 0 2133 128BANK 2 ChannelB-DIMM0 0 2133 128

 

高级例子,讲上述过程写成PYTHON程序,并利用Python的字符处理能力格式化信息

代码如下:

import os import ctypes Drive = os.environ['SYSTEMDRIVE'] GetRamSlots = "wmic memphysical get memorydevices" GetRamSoltCapacity = "wmic memphysical get MaxCapacity" GetUsedSolt = "wmic MEMORYCHIP get Banklabel,DeviceLocator,MemoryType,TypeDetail,speed" GetFreeMemory = 'systeminfo | findstr /'+ Drive +'"Total Physical Memory" /'+Drive+'"Available Physical Memory"' class disable_file_system_redirection: _disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection _revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection def __enter__(self): self.old_value = ctypes.c_long() self.success = self._disable(ctypes.byref(self.old_value)) def __exit__(self, type, value, traceback): if self.success: self._revert(self.old_value) with disable_file_system_redirection(): Run_GetRamSlots = os.popen(GetRamSlots).read() Run_GetRamSoltCapacity = os.popen(GetRamSoltCapacity).read() Run_GetUsedSolt = os.popen(GetUsedSolt).read() Run_GetFreeMemory = os.popen(GetFreeMemory).read() print("Getting RAM details.. \n") for i in [i.strip() for i in Run_GetRamSlots.split('\n') if 'MemoryDevices' not in i if i.strip()]: print ("The Number of RAM slots available:"+i+"\n") for i in [i.strip() for i in Run_GetRamSoltCapacity.split('\n') if 'MaxCapacity' not in i if i.strip()]: B = int(i) GB = 1024*1024.0 Convert = B/GB print ("The capacity of each RAM per slot is:",Convert , "GB") print ("\n") c = 0 for i in [i.strip() for i in Run_GetUsedSolt.split('\n') if 'BankLabel' not in i if i.strip()]: c =c+1 print ("The number of used slot(s):", c) print ("The details of the used slots:") print (Run_GetUsedSolt) print ("The installed RAM memory details:") print (Run_GetFreeMemory) print ("\n")

 

输出如下:

The Number of RAM slots available:4 The capacity of each RAM per slot is: 32.0 GB The number of used slot(s): 2 The details of the used slots: BankLabel DeviceLocator MemoryType Speed TypeDetail BANK 0 ChannelA-DIMM0 0 2133 128 BANK 2 ChannelB-DIMM0 0 2133 128 The installed RAM memory details: Total Physical Memory: 16,135 MB Available Physical Memory: 5,961 MB

  

ref: https://scripts.comodo.com/frontend/web/topic/show-available-ram-sockets-on-the-motherboard

 



【本文地址】

公司简介

联系我们

今日新闻


点击排行

实验室常用的仪器、试剂和
说到实验室常用到的东西,主要就分为仪器、试剂和耗
不用再找了,全球10大实验
01、赛默飞世尔科技(热电)Thermo Fisher Scientif
三代水柜的量产巅峰T-72坦
作者:寞寒最近,西边闹腾挺大,本来小寞以为忙完这
通风柜跟实验室通风系统有
说到通风柜跟实验室通风,不少人都纠结二者到底是不
集消毒杀菌、烘干收纳为一
厨房是家里细菌较多的地方,潮湿的环境、没有完全密
实验室设备之全钢实验台如
全钢实验台是实验室家具中较为重要的家具之一,很多

推荐新闻


图片新闻

实验室药品柜的特性有哪些
实验室药品柜是实验室家具的重要组成部分之一,主要
小学科学实验中有哪些教学
计算机 计算器 一般 打孔器 打气筒 仪器车 显微镜
实验室各种仪器原理动图讲
1.紫外分光光谱UV分析原理:吸收紫外光能量,引起分
高中化学常见仪器及实验装
1、可加热仪器:2、计量仪器:(1)仪器A的名称:量
微生物操作主要设备和器具
今天盘点一下微生物操作主要设备和器具,别嫌我啰嗦
浅谈通风柜使用基本常识
 众所周知,通风柜功能中最主要的就是排气功能。在

专题文章

    CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭