Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get system information(CPU speed-Total RAM-Graphic Card model etc.) under Windows

I searched a lot but couldn't find anything useful. Is this possible to get system information like;

CPU: Intel Core i7-3770K CPU @3.5Ghz
RAM: 8GB
Graphic Card: NVIDIA GeForce GTX 680

under Windows? How can I reach this output?

Edit: platform.processor() is not giving the output that I want. So that is useless for me.

like image 965
GLHF Avatar asked Jun 29 '16 15:06

GLHF


People also ask

How do I check my CPU and GPU on my laptop?

Open the Start menu or go to the desktop search bar, start typing System information, and select it when the option appears. Click the + symbol next to Components in the upper left, and then click Display on the expanded list. You'll see the name of your graphics card, its type, and device ID.

How do I check my CPU and RAM?

To check your basic computer specs in Windows 10, click on the Windows start button, then click on the gear icon for Settings. In the Windows Settings menu, select System. Scroll down and select About. From here, you will see specs for your processor, RAM, and other system info.

How do I check my graphics card and RAM?

In the Display Settings box, select Advanced Display Settings and then choose the Display Adapter properties option. On the Adapter tab in the box, you should see the brand of the graphics card and its memory amount listed.


1 Answers

I've been wondering how to do this myself for a while now, so I dug around a bit and came up with this solution using wmi (which requires pywin32). Of course, it goes without saying, this only works on Windows machines (and the question has the Windows tag).

import wmi

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))

Output example:

OS Name: Microsoft Windows 7 Ultimate 
OS Version: 6.1.7601 7601
CPU: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz
RAM: 15.9443855286 GB
Graphics Card: NVIDIA GeForce GTX 960

You can install both required packages via pip:

pip install --upgrade wmi
pip install --upgrade pypiwin32

To see what other variables you can access in various Win32 controller classes, take a look at this documentation:

  • Win32_ComputerSystem
  • Win32_OperatingSystem
  • Win32_Processor
  • Win32_VideoController

Related answer found on SO: https://stackoverflow.com/a/11785020/295246


Update: For System RAM, you can use either os_info.TotalVisibleMemorySize (returns the value in kilobytes) or computer_info.TotalPhysicalMemory (returns the value in bytes). If you use the latter, you can use hurry.filesize to quickly convert it to a pretty human readable string.

For example:

from hurry.filesize import size
...
size(int(computer_info.TotalPhysicalMemory))

Which in my case outputs: 15G You can even modify the G to whatever else you want. See this SO answer for more info: https://stackoverflow.com/a/5194348/295246

like image 137
HEADLESS_0NE Avatar answered Oct 18 '22 20:10

HEADLESS_0NE