Page 1 of 1

Function to Change Mac on Win XP in Python

Posted: 21 Apr 2006, 23:10
by maboroshi
Here is a function to change your mac address in Python

Code: Select all



def changemac():
    networkcard = OpenKey(
    HKEY_LOCAL_MACHINE,
    r"SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0001",
    0, KEY_WRITE)
    mykey = "NetworkAddress"
    theend = raw_input("Please Enter The Mac Address to change to")
    try:
        value = SetValueEx(networkcard, mykey, 0, REG_SZ, theend)
        print "Mac Successfully Changed to \n\n" + theend)
        print "\n\n You now need to run \n http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311272 \n\n")
        print "Or reboot your computer Easiest Choice\n\n")
    except:
        print "Failed Setting Mac")
    CloseKey(networkcard)

Cheers Maboroshi

Posted: 22 Apr 2006, 03:41
by bad_brain
sweet! :D
umm...is this registry key already existing including the original MAC?
or is is a new key? in the first case it might be useful to have the opportunity to save the original MAC to a textfile before changing it...just a suggestion.. :)

Thats an idea

Posted: 22 Apr 2006, 12:11
by maboroshi
Thats an idea but would take all the fun out of it

hehe :D

I'll see what I can do ;)