473,500 Members | 1,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Lets suppose, I want a listing of what hardware and software is
installed on my
windows box. Can I do that with Python?

Apr 30 '07 #1
1 1824
On Apr 30, 10:47 am, walterbyrd <walterb...@iname.comwrote:
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: http://tgolden.sc.sabren.com/python/wmi_cookbook.html

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:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Curr entVersion\Uninstall

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,
sSubKeyName=r"Software\Microsoft\Windows\CurrentVe rsion\Uninstall")
for subkey in names:
try:
appFile.write('+++++++++++++++++++++++++++++++++++ +++++++++++++
+++++++++++++++++++++++++\n\n')
key = OpenKey(HKEY_LOCAL_MACHINE,
r"Software\Microsoft\Windows\CurrentVersion
\Uninstall\%s" % subkey,0, KEY_ALL_ACCESS)
try:
temp = QueryValueEx(key, 'DisplayName')
display = str(temp[0])
appFile.write('Display Name: ' + display + '\nRegkey: ' +
subkey + '\n')
except:
appFile.write('Regkey: ' + subkey + '\n')
except:
print 'Error opening key'

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

That should get you going.

Mike

Apr 30 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3825
by: Logan | last post by:
Several people asked me for the following HOWTO, so I decided to post it here (though it is still very 'alpha' and might contain many (?) mistakes; didn't test what I wrote, but wrote it - more or...
1
4212
by: Jeremy C. Reed | last post by:
Configuring gramps (genealogy software) says: checking Python bindings for gtk... ok checking Python bindings for GNOME... ok checking Python bindings for gconf... Traceback (most recent call...
2
1603
by: Rien Kok | last post by:
Hi, I have a strange problem. I want to install Plone (Plone2-2.0.0rh-2.i386.rpm) Because Plone 2.0 needs Python 2.3.3, I installed Python 2.3.3 from source (Python-2.3.3.tar). Everything...
35
3026
by: Michael Kearns | last post by:
I've been using python to write a simple 'launcher' for one of our Java applications for quite a while now. I recently updated it to use python 2.4, and all seemed well. Today, one of my...
5
43184
by: Paul Horn | last post by:
Hi I need some help here. I would appreciate it if any one can help me. My 2 questions is this: 1. How do you get a list of installed applications on Windows? 2. How do I get a program's...
4
3362
by: Alia Khouri | last post by:
Can we open up the discussion here about how to improve setuptools which has become the de facto standard for distributing / installing python software. I've been playing around with ruby's gems...
8
3263
by: karthikbalaguru | last post by:
Hi, One of my python program needs tkinter to be installed to run successfully. I am using Redhat 9.0 and hence tried installing by copying the tkinter-2.2.2-36.i386.rpm alone from the CD 3 to...
7
1610
by: greg | last post by:
Thomas Philips wrote: Have a look in /Library/Frameworks/Python.framework/Versions/2.5 You can't -- this feature only exists in the Search window, which is a different kind of window...
8
2120
by: timotoole | last post by:
Hi all, I'm trying to get python to work with cgi for a small intranet site, however even a simply "hello world test isn't working". Here is the test file: #!/usr/bin/python # -*- coding:...
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7229
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3108
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
311
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.