python wmi模块 硬件信息参数详情

import wmi

namespace = "rootcimv2"
client = wmi.WMI(computer="Anec",namespace=namespace)


# for sys in client.Win32_OperatingSystem():
#     print(sys.Caption)                  #Microsoft Windows 10 企业版
#     print(sys.CSName)                   #"HEQUN"
#     print(sys.InstallDate)              #20200729154515.000000+480
#     print(sys.OSArchitecture)           #64 位
#     print(sys.WindowsDirectory)         #C:Windows
#     print(sys.SerialNumber)             #00328-90000-00000-AAOEM
r"""
instance of Win32_OperatingSystem
{
BootDevice = "\Device\HarddiskVolume3";
BuildNumber = "18362";
BuildType = "Multiprocessor Free";
Caption = "Microsoft Windows 10 企业版";
CodeSet = "936";
CountryCode = "86";
CreationClassName = "Win32_OperatingSystem";
CSCreationClassName = "Win32_ComputerSystem";
CSName = "HEQUN";
CurrentTimeZone = 480;
DataExecutionPrevention_32BitApplications = TRUE;
DataExecutionPrevention_Available = TRUE;
DataExecutionPrevention_Drivers = TRUE;
DataExecutionPrevention_SupportPolicy = 2;
Debug = FALSE;
Description = "";
Distributed = FALSE;
EncryptionLevel = 256;
ForegroundApplicationBoost = 2;
FreePhysicalMemory = "24657648";
FreeSpaceInPagingFiles = "2088224";
FreeVirtualMemory = "25999016";
InstallDate = "20200729154515.000000+480";
LastBootUpTime = "20200930173228.500000+480";
LocalDateTime = "20201020094456.118000+480";
Locale = "0804";
Manufacturer = "Microsoft Corporation";
MaxNumberOfProcesses = 4294967295;
MaxProcessMemorySize = "137438953344";
MUILanguages = {"zh-CN"};
Name = "Microsoft Windows 10 企业版|C:\Windows|\Device\Harddisk0\Partition3";
NumberOfProcesses = 179;
NumberOfUsers = 9;
OperatingSystemSKU = 4;
Organization = "Organization";
OSArchitecture = "64 位";
OSLanguage = 2052;
OSProductSuite = 256;
OSType = 18;
PortableOperatingSystem = FALSE;
Primary = TRUE;
ProductType = 1;
RegisteredUser = "admin";
SerialNumber = "00328-90000-00000-AAOEM";
ServicePackMajorVersion = 0;
ServicePackMinorVersion = 0;
SizeStoredInPagingFiles = "2097152";
Status = "OK";
SuiteMask = 272;
SystemDevice = "\Device\HarddiskVolume5";
SystemDirectory = "C:\Windows\system32";
SystemDrive = "C:";
TotalVirtualMemorySize = "35570268";
TotalVisibleMemorySize = "33473116";
Version = "10.0.18362";
WindowsDirectory = "C:\Windows";
};
"""

# for i in client.Win32_Processor():
#     print(i.Name)                   # Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
#     print(i.ThreadCount)            # 8
r"""
instance of Win32_Processor
{
AddressWidth = 64;
Architecture = 9;
AssetTag = "To Be Filled By O.E.M.";
Availability = 3;
Caption = "Intel64 Family 6 Model 158 Stepping 9";
Characteristics = 252;
CpuStatus = 1;
CreationClassName = "Win32_Processor";
CurrentClockSpeed = 3601;
CurrentVoltage = 9;
DataWidth = 64;
Description = "Intel64 Family 6 Model 158 Stepping 9";
DeviceID = "CPU0";
ExtClock = 100;
Family = 198;
L2CacheSize = 1024;
L3CacheSize = 8192;
L3CacheSpeed = 0;
Level = 6;
LoadPercentage = 22;
Manufacturer = "GenuineIntel";
MaxClockSpeed = 3601;
Name = "Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz";
NumberOfCores = 4;
NumberOfEnabledCore = 4;
NumberOfLogicalProcessors = 8;
PartNumber = "To Be Filled By O.E.M.";
PowerManagementSupported = FALSE;
ProcessorId = "BFEBFBFF000906E9";
ProcessorType = 3;
Role = "CPU";
SecondLevelAddressTranslationExtensions = TRUE;
SerialNumber = "To Be Filled By O.E.M.";
SocketDesignation = "CPU0";
Status = "OK";
StatusInfo = 3;
SystemCreationClassName = "Win32_ComputerSystem";
SystemName = "HEQUN";
ThreadCount = 8;
UpgradeMethod = 1;
Version = "";
VirtualizationFirmwareEnabled = TRUE;
VMMonitorModeExtensions = TRUE;
};
"""

# print(len(client.Win32_PhysicalMemory()))
# for i2 in client.Win32_PhysicalMemory():
#     print(int(i2.Capacity) / 1024 / 1024 / 1024)    # 17179869184
#     print(i2.PartNumber)                            # KHX2666C16/16G
#     print(i2.SerialNumber)                          # EF19207A
#     print(i2.Speed)                                 # 2400
#     print(i2.Tag)                                   # Physical Memory 2
r""" 
level 2
instance of Win32_PhysicalMemory
{
Attributes = 2;
BankLabel = "ChannelB";
Capacity = "17179869184";
Caption = "物理内存";
ConfiguredClockSpeed = 2400;
CreationClassName = "Win32_PhysicalMemory";
DataWidth = 64;
Description = "物理内存";
DeviceLocator = "DIMM1";
FormFactor = 8;
InterleaveDataDepth = 0;
InterleavePosition = 0;
Manufacturer = "Kingston";
MemoryType = 0;
Name = "物理内存";
PartNumber = "KHX2666C16/16G      ";
PositionInRow = 1;
SerialNumber = "775A42C6";
SMBIOSMemoryType = 26;
Speed = 2400;
Tag = "Physical Memory 0";
TotalWidth = 64;
TypeDetail = 16512;
};
"""

# print(len(client.Win32_DiskDrive()))                    # 3
# for i3 in client.Win32_DiskDrive():
#     print(i3.InterfaceType)                             # SCSI
#     print(i3.Model)                                     # Samsung SSD 850 EVO 250GB
#     print(i3.SerialNumber)                              # S2R7NX0K142965L
#     print(round(int(i3.Size) / 1024 / 1024 / 1024))     # 233
r"""
instance of Win32_DiskDrive
{
BytesPerSector = 512;
Capabilities = {3, 4};
CapabilityDescriptions = {"Random Access", "Supports Writing"};
Caption = "Samsung SSD 850 EVO 250GB";
ConfigManagerErrorCode = 0;
ConfigManagerUserConfig = FALSE;
CreationClassName = "Win32_DiskDrive";
Description = "磁盘驱动器";
DeviceID = "\\.\PHYSICALDRIVE2";
FirmwareRevision = "EMT02B6Q";
Index = 2;
InterfaceType = "SCSI";
Manufacturer = "(标准磁盘驱动器)";
MediaLoaded = TRUE;
MediaType = "Fixed hard disk media";
Model = "Samsung SSD 850 EVO 250GB";
Name = "\\.\PHYSICALDRIVE2";
Partitions = 1;
PNPDeviceID = "SCSI\DISK&VEN_SAMSUNG&PROD_SSD\4&2C691D24&0&000300";
SCSIBus = 0;
SCSILogicalUnit = 0;
SCSIPort = 1;
SCSITargetId = 3;
SectorsPerTrack = 63;
SerialNumber = "S2R7NX0K142965L";
Signature = 4026089862;
Size = "250056737280";
Status = "OK";
SystemCreationClassName = "Win32_ComputerSystem";
SystemName = "HEQUN";
TotalCylinders = "30401";
TotalHeads = 255;
TotalSectors = "488392065";
TotalTracks = "7752255";
TracksPerCylinder = 255;
};

"""

# print(len(client.Win32_NetworkAdapterConfiguration(IPEnabled=1)))
# for i4 in client.Win32_NetworkAdapterConfiguration(IPEnabled=1):
#     print(i4.DefaultIPGateway)
#     print(i4.DNSServerSearchOrder)
#     print(i4.IPAddress)
#     print(i4.IPSubnet)
#     print(i4.MACAddress)
r"""
instance of Win32_NetworkAdapterConfiguration
{
Caption = "[00000010] Intel(R) Ethernet Connection (2) I219-LM";
DatabasePath = "%SystemRoot%\System32\drivers\etc";
DefaultIPGateway = {"10.2.1.1"};
DefaultTTL = 64;
Description = "Intel(R) Ethernet Connection (2) I219-LM";
DHCPEnabled = FALSE;
DNSDomainSuffixSearchOrder = {"yujiahui.com"};
DNSEnabledForWINSResolution = FALSE;
DNSHostName = "hequn";
DNSServerSearchOrder = {"10.1.88.20", "10.1.88.21"};
DomainDNSRegistrationEnabled = FALSE;
FullDNSRegistrationEnabled = TRUE;
GatewayCostMetric = {256};
Index = 10;
InterfaceIndex = 17;
IPAddress = {"10.2.1.111", "fe80::6c48:6732:3ba3:e1a9"};
IPConnectionMetric = 25;
IPEnabled = TRUE;
IPFilterSecurityEnabled = FALSE;
IPSecPermitIPProtocols = {};
IPSecPermitTCPPorts = {};
IPSecPermitUDPPorts = {};
IPSubnet = {"255.255.255.0", "64"};
MACAddress = "18:60:24:8A:86:6C";
PMTUBHDetectEnabled = TRUE;
PMTUDiscoveryEnabled = TRUE;
ServiceName = "e1dexpress";
SettingID = "{F4BBD4DF-9843-48F3-9C01-BEF21A00B85C}";
TcpipNetbiosOptions = 0;
WINSEnableLMHostsLookup = TRUE;
WINSScopeID = "";
};
"""

# for i5 in client.Win32_BIOS():
#     print(i5)
r"""
instance of Win32_BIOS
{
BiosCharacteristics = {7, 8, 11, 12, 15, 16, 19, 26, 27, 28, 29, 32, 33, 40, 41, 42, 43};
BIOSVersion = {"HPQOEM - 0", "N51 Ver. 01.63", "HP - 1003F"};
Caption = "N51 Ver. 01.63";
CurrentLanguage = "enUS";
Description = "N51 Ver. 01.63";
EmbeddedControllerMajorVersion = 5;
EmbeddedControllerMinorVersion = 55;
InstallableLanguages = 14;
ListOfLanguages = {"enUS", "daDK", "nlNL", "fiFI", "frFR", "deDE", "itIT", "jaJP", "noNO", "ptPT", "esES", "svSE", "zhCN", "zhTW"};
Manufacturer = "HP";
Name = "N51 Ver. 01.63";
PrimaryBIOS = TRUE;
ReleaseDate = "20171005000000.000000+000";
SerialNumber = "4CV807WPFK";
SMBIOSBIOSVersion = "N51 Ver. 01.63";
SMBIOSMajorVersion = 2;
SMBIOSMinorVersion = 7;
SMBIOSPresent = TRUE;
SoftwareElementID = "N51 Ver. 01.63";
SoftwareElementState = 3;
Status = "OK";
SystemBiosMajorVersion = 1;
SystemBiosMinorVersion = 63;
TargetOperatingSystem = 0;
Version = "HPQOEM - 0";
};
"""
原文地址:https://www.cnblogs.com/Anec/p/13882553.html