Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31528

Re: Change computername

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'else:': 0.03; '"win32"': 0.09; 'effect.': 0.09; 'success:': 0.09; 'oct': 0.16; 'rights,': 0.16; 'subject:Change': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'admin': 0.18; 'windows': 0.19; 'module': 0.19; 'import': 0.21; 'ctypes': 0.22; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'hello,': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'success': 0.63; 'skip:w 60': 0.84; 'to:name:python': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=Ra5SZb0P+j63zn3x+34o519iwEh4g2h8WXbhwnGRzzc=; b=AXqbKQzhjgkkH/XdAMt4qpGHTuGQkJPQQ21PmKSBCjKoET02pNkI3DAd7Skszjfh1U MnXdK6ZjJVh4i3p3Pb36hJjd0IVatnpBT8OVpnjxYFmD5AKWnUqy5XNO2oNXvSLHitHp UKZrQPpggq64xTQFNY23WGxFcjc8uxgnlagFX8LAJWaKKNCq7RdQ2fkocvdLz7Gs0/J7 RcJOl/WJXHAllu1CPjHPFb+onaNtVYl4sEaPhw7sAVxKs3rfQlq3xn9ePo0BSo0a/jDE KpK5hdUPGFOLsY4RPAgKVt+ySOpIyuaAN22rsyomGOirIhAcemiKyMIpX8m1vxybDuJk pY/Q==
MIME-Version 1.0
In-Reply-To <CAKhY55NpUnZ3PdZczo2kv-DezMsz0TjWAvPST5cRZyAY30MPaA@mail.gmail.com>
References <CAKhY55NpUnZ3PdZczo2kv-DezMsz0TjWAvPST5cRZyAY30MPaA@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Wed, 17 Oct 2012 11:47:12 -0600
Subject Re: Change computername
To Python <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2356.1350496064.27098.python-list@python.org> (permalink)
Lines 23
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1350496064 news.xs4all.nl 6855 [2001:888:2000:d::a6]:54479
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:31528

Show key headers only | View raw


On Wed, Oct 17, 2012 at 8:07 AM, Anatoli Hristov <tolidtm@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.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Change computername Ian Kelly <ian.g.kelly@gmail.com> - 2012-10-17 11:47 -0600

csiph-web