我正在创建一个程序,该程序可以检索Windows计算机的所有硬件和软件信息,问题是我无法使用python生成一个文件,该文件可以提供所有我需要的信息。我正在使用wmi库来获取一些信息,但找不到所有需要的信息。有没有办法获取所有信息?
我使用了os和wmi库,但是找不到每个插槽的ram信息,电池循环次数和完整的计算机信息
print('Battery information')
c = wmi.WMI()
t = wmi.WMI(moniker = "//./root/wmi")
batts1 = c.CIM_Battery(Caption = 'Portable Battery')
for i, b in enumerate(batts1):
print ('Battery %d Design Capacity: %d mWh' % (i, b.DesignCapacity or 0))
batts = t.ExecQuery('Select * from BatteryFullChargedCapacity')
for i, b in enumerate(batts):
print ('Battery %d Fully Charged Capacity: %d mWh' %
(i, b.FullChargedCapacity))
batts = t.ExecQuery('Select * from BatteryStatus where Voltage > 0')
for i, b in enumerate(batts):
print ('\nBattery %d *****' % i)
print ('Tag: ' + str(b.Tag))
print ('Name: ' + b.InstanceName)
print ('PowerOnline: ' + str(b.PowerOnline))
print ('Voltage: ' + str(b.Voltage))
print ('DischargeRate: ' + str(b.DischargeRate))
print ('ChargeRate: ' + str(b.ChargeRate))
print ('RemainingCapacity: ' + str(b.RemainingCapacity))
print ('Active: ' + str(b.Active))
print ('Critical: ' + str(b.Critical))
print ('Cycles: ')
print ('Original capacity ')
print ('Current capacity ')
print ('')
print ('System information')
computer = wmi.WMI()
computer_info = computer.Win32_ComputerSystem()[0]
os_info = computer.Win32_OperatingSystem()[0]
proc_info = computer.Win32_Processor()[0]
gpu_info = computer.Win32_VideoController()[0]
os_name = os_info.Name.encode('utf-8').split(b'|')[0]
os_version = ' '.join([os_info.Version, os_info.BuildNumber])
system_ram = float(os_info.TotalVisibleMemorySize) / 1048576 # KB to GB
print('OS Name: {0}'.format(os_name))
print('OS Version: {0}'.format(os_version))
print('CPU: {0}'.format(proc_info.Name))
print('RAM: {0} GB'.format(system_ram))
print('Graphics Card: {0}'.format(gpu_info.Name))
print ('')
#Diskdrive Size, completed
print ('DiskDrive information')
total,used, free = shutil.disk_usage('/')
print('total: %d GB' % (total // (2**30)))
print('Used: %d GB' % (used // (2**30)))
print('Free: %d GB' % (free // (2**30)))
print ('')