Change computername

Ian Kelly ian.g.kelly at gmail.com
Wed Oct 17 13:47:12 EDT 2012


On Wed, Oct 17, 2012 at 8:07 AM, Anatoli Hristov <tolidtm at gmail.com> wrote:
> Hello,
>
> Can you please help me out how can I change the computername of
> windows XP with or without the "WIN32" module ?

Untested:

from ctypes import *

ComputerNamePhysicalDnsHostname = 5

computer_name = u'COMPUTER'

success = windll.kernel32.SetComputerNameExW(ComputerNamePhysicalDnsHostname,
                                             computer_name)
if success:
    print("Name changed")
else:
    print("Failed")

The process will need admin rights, and the computer will need to be
rebooted before the change will take effect.



More information about the Python-list mailing list