Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Change computername

32 views
Skip to first unread message

Anatoli Hristov

unread,
Oct 17, 2012, 10:07:46 AM10/17/12
to pytho...@python.org
Hello,

Can you please help me out how can I change the computername of
windows XP with or without the "WIN32" module ?

Thanks

Ian Kelly

unread,
Oct 17, 2012, 1:47:12 PM10/17/12
to Python
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.

Anatoli Hristov

unread,
Oct 18, 2012, 2:41:00 AM10/18/12
to Ian Kelly, Python
Thank you,

I will test this, will keep you posted.

Anatoli
> --
> http://mail.python.org/mailman/listinfo/python-list

Anatoli Hristov

unread,
Oct 18, 2012, 4:22:55 AM10/18/12
to Ian Kelly, Python
It does not work the result is "0"

And I don't find any documentation about it :(

Chris Angelico

unread,
Oct 18, 2012, 6:13:39 AM10/18/12
to pytho...@python.org
On Thu, Oct 18, 2012 at 7:22 PM, Anatoli Hristov <tol...@gmail.com> wrote:
> It does not work the result is "0"
>
> And I don't find any documentation about it :(

Microsoft's official documentation can usually be found at the other
end of a web search. In this case:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms724931(v=vs.85).aspx

You may need to call GetLastError to find out the actual problem.

ChrisA
Message has been deleted
0 new messages