I cannot read information from Windows Registry using python on windows 8.1

This script returns the MAC addresses and network names of all the WiFi networks you have joined. But when I run on my pychram python 2.7.12 it gives me the following out put:

C:\Python27\python.exe C:/Users/Bdd/PycharmProjects/untitled6/pp.py
Process finished with exit code 0

from _winreg import *

def val2addr(val):

    addr = ''

    for ch in val:

        addr += '%02x '% ord(ch)

    addr = addr.strip(' ').replace(' ', ':')[0:17]

    return addr

def printNets():

    print '[+] '

    net = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"+\
    key = OpenKey(HKEY_LOCAL_MACHINE, net)

    print '\n[*] Networks You have Joined.'

    for i in range(100):
            guid = EnumKey(key, i)

            netKey = OpenKey(key, str(guid))

            (n, addr, t) = EnumValue(netKey, 5)

            (n, name, t) = EnumValue(netKey, 4)

            macAddr = val2addr(addr)

            netName = str(name)

            print '[+] ' + netName + ' ' + macAddr



def main():


if __name__ == "__main__":


Open in new window

zrdad montAsked:
Who is Participating?
David Johnson, CD, MVPConnect With a Mentor OwnerCommented:
32 bit python on x64 system you need to specify you want x64 version of registry and not syswow64 section

key = OpenKey(HKEY_LOCAL_MACHINE, net, 0, KEY_READ | KEY_WOW64_64KEY)

Open in new window

You may need administrative permissions (run as administrator) test via command prompt
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList

Open in new window

zrdad montAuthor Commented:
Thanks, solution worked perfectly fine
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.