how to read hardware info on Win NT

Mark Gash mgash at trisystems.co.uk
Wed Apr 10 10:50:20 EDT 2002


>Thanks for the __winreg hint. Looks like I have to get some infos
>about the registry because I have no idea how to find the right key.
>
>If anyone knows, please tell me.
>
>I need the id of my ethernet card for a license documentation tool we
>want to write in Python. As many commercial softwares are using this
>id for generating the license keys etc. I thought there should be
>module in Python.  Maybe there is a modul for commercial distribution
>of Python software?

Marcus,
With further investigation, I cannot find where the MAC address of the card
is in registry (I assume that you require the MAC address when you say that
you want the id of your Ethernet card).

I am also assuming that you are using a win32 machine.

There are two other ways that I can think of in order to get your info:-

1. Run the command 'ipconfig /all' and pipe the results into a text file
that you can then search i.e.
	'ipconfig /all > c:\ipdetails.txt'

2. The nbtstat command will report the MAC address of a card, so that for
example, you could use the command 'nbtstat -a <machinename>' and pipe the
results out to a text file, i.e.
	'nbtstat -a mypc > c:\nbtdetails.txt' 

Once the correct command has been tested, then from your python script wrap
it up in an os.system call.

So, we will end up with something along the lines of :-

import os
os.system("ipconfig /all > c:\ipdetails.txt")

or 

import os
os.system("nbtstat -a mypc > c:\nbtdetails.txt")

Then you will have to add some string handling/searching to find the MAC
address and process it as required.

Hope this helps.

Kind Regards,

Mark Gash
Consultant
TriSystems Ltd.
020 7264 0440
mgash at trisystems.co.uk





-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.





More information about the Python-list mailing list