Can python find HW/SW installed on my PC - like Belarc?

kyosohma at kyosohma at
Mon Apr 30 12:24:34 EDT 2007

On Apr 30, 10:47 am, walterbyrd <walterb... at> wrote:
> Lets suppose, I want a listing of what hardware and software is
> installed on my
> windows box. Can I do that with Python?

Yes, it is possible for Windows. I don't know how to grab the info for
other OS's though. There is a caveat that is annoying. If the software
doesn't put itself into the registry somehow, it is much harder to
discover if it is indeed installed.

For hardware, you'll need the WMI module and the win32 module. For the
computer memory and the name of the PC, see below:

c = wmi.WMI()
for i in c.Win32_ComputerSystem():
        mem = int(i.TotalPhysicalMemory)
        compname = i.Name

For the CPU:

for i in c.Win32_Processor ():
        cputype = i.Name

For other cool WMI tricks:

For the majority of the software on your system, you'll want to
iterate over the following registry key (and its subkeys) using the
_winreg module and WMI's Registry() function:


Some code that worked for me (may need modification for your setup):

from _winreg import HKEY_LOCAL_MACHINE, KEY_ALL_ACCESS, OpenKey,
EnumValue, QueryValueEx

r = wmi.Registry ()
result, names = r.EnumKey (hDefKey=HKEY_LOCAL_MACHINE,
for subkey in names:
        key = OpenKey(HKEY_LOCAL_MACHINE,
\Uninstall\%s" % subkey,0, KEY_ALL_ACCESS)
            temp = QueryValueEx(key, 'DisplayName')
            display = str(temp[0])
            appFile.write('Display Name: ' + display + '\nRegkey: ' +
subkey + '\n')
            appFile.write('Regkey: ' + subkey + '\n')
       print 'Error opening key'

# appFile is where I write the list to. You can just print to console.

That should get you going.


More information about the Python-list mailing list