On 8/18/2012 10:12 AM, šãñ wrote:

I need to find some way how i can get mac address of windows 7 in python.
Windows 7 does not have a MAC address. It is an operating system.

Ethernet adapters have MAC addresses. Your computer will have one or more Ethernet adapter.
From a command prompt enter
ipconfig /all

You will see something like (this is from MY computer, Windows 2008 Server, similar to Win 7):

Windows IP Configuration

   Host Name . . . . . . . . . . . . : xxx
   Primary Dns Suffix  . . . . . . . : xxx
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : Yes
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : xxx

Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . :
Description . . . . . . . . . . . : Intel(R) 82579LM Gigabit Network Connecti
on
   Physical Address. . . . . . . . . : 44-37-E6-63-86-B9
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::e102:17d6:8b9d:43be%10(Preferred)
   IPv4 Address. . . . . . . . . . . : 192.168.0.190(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.0.1
   DHCPv6 IAID . . . . . . . . . . . : 172242918
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-16-8E-75-AE-44-37-E6-63-86-B9

   DNS Servers . . . . . . . . . . . : ::1
                                       127.0.0.1
   NetBIOS over Tcpip. . . . . . . . : Enabled

Ethernet adapter VMware Network Adapter VMnet1:

   Connection-specific DNS Suffix  . :
Description . . . . . . . . . . . : VMware Virtual Ethernet Adapter for VMnet
1
   Physical Address. . . . . . . . . : 00-50-56-C0-00-01
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::7c33:3774:7709:c50d%15(Preferred)
   IPv4 Address. . . . . . . . . . . : 192.168.29.1(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :
   DHCPv6 IAID . . . . . . . . . . . : 419450966
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-16-8E-75-AE-44-37-E6-63-86-B9

   DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                       fec0:0:0:ffff::2%1
                                       fec0:0:0:ffff::3%1
   NetBIOS over Tcpip. . . . . . . . : Enabled

etc.

Each Ethernet adapter has a Physical Address (MAC Address).

When you run ipconfig /all - if you see only one Physical Address, then that is the one you want.

If you see more than one then you must decide which Ethernet adapter you want.

Then you use Popen (in subprocess module) to run ipconfig /all, capture the output and parse it for the desired Ethernet adapter, then parse that section for the Physical Address.

There may be another (better?, easier?) way but this will work.

--
Bob Gailer
919-636-4239
Chapel Hill NC

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to