Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.029 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'to)': 0.07; "(it's": 0.09; 'exceptions': 0.09; ';-)': 0.14; 'am,': 0.14; 'wrote:': 0.14; 'subject:interface': 0.16; 'windows:': 0.16; 'wmi': 0.16; 'subject:address': 0.16; "wouldn't": 0.18; 'why.': 0.19; 'interface': 0.20; '(or': 0.22; 'header:In-Reply-To:1': 0.22; 'issue,': 0.23; 'received:209.85.214.174': 0.23; 'received:mail- iw0-f174.google.com': 0.23; 'skip:( 30': 0.24; 'stored': 0.25; 'object': 0.27; '(you': 0.29; 'message-id:@gmail.com': 0.30; 'all.': 0.30; 'sharing': 0.31; 'import': 0.32; 'to:addr:python- list': 0.32; 'initial': 0.32; '...': 0.32; 'connection': 0.33; 'uses': 0.34; 'received:192.168.1': 0.34; 'received:192': 0.34; 'difference': 0.35; 'print': 0.35; 'header:User-Agent:1': 0.35; 'think': 0.36; 'received:192.168': 0.37; 'assigned': 0.37; 'received:209.85': 0.37; 'useful': 0.37; 'strings': 0.38; 'received:google.com': 0.38; 'but': 0.38; 'center': 0.38; 'tim': 0.39; 'received:209.85.214': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'said': 0.39; 'whatever': 0.39; 'would': 0.40; "it's": 0.40; 'header:Received:5': 0.40; 'might': 0.40; 'making': 0.62; 'card': 0.63; 'blank': 0.65; 'golden': 0.68; 'subject:Get': 0.74; '06:12': 0.84; 'offline,': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; bh=mEo9AEsbz3YTMk95NcVYz9jcw8oYzdGyDRIrOIv2Qzw=; b=Xsx2Whux/B8f3Xr58kwBDs0iBq/Aukpj5Q5sd/ogHZDdATz8ypvHyxpo5V1GYTXciR Nw9VSZn+bKijnhcqUe7gZgBwM+zKMEIGBR3utoZ/+BeJA2buTASDWIsGLqSqXAU32DWd VZUS7v1SMnJsEoqoMG+yb9UepQoMhFCyQNa/w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; b=R9NhZu+jhAUwh0vRMI5JcaTPOFnnCkYhmAoUyH0zKEOyUsS8Sqfh32m6YZJcQe0GV7 PhoPPA6bDM9npHaT06gyILhWc8L4dIHXCBe/oPP/4zQgXKa31MaLpVksn68M7MlZuavf l7kFyZ8zx3kTKpMqvye8GbWLFzWcUPN8KjiI8= Date: Sun, 15 May 2011 16:14:18 -0500 From: Andrew Berg User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 ThunderBrowse/3.3.5 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Get the IP address of WIFI interface References: <4DCFB507.2040007@timgolden.me.uk> In-Reply-To: <4DCFB507.2040007@timgolden.me.uk> X-Enigmail-Version: 1.1.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 21 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1305494064 news.xs4all.nl 41114 [::ffff:82.94.164.166]:57233 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5447 On 2011.05.15 06:12 AM, Tim Golden wrote: > ... and for Windows: > > > import wmi > > for nic in wmi.WMI ().Win32_NetworkAdapterConfiguration (IPEnabled=1): > print nic.Caption, nic.IPAddress > > One thing I found out about Win32_NetworkAdapterConfiguration is that it only contains /current/ information and not the stored info that it uses when making an initial connection (you can see and edit this info in the Network and Sharing Center applet). The difference is that if you're offline, that WMI object will have no useful info at all. You can find the info in the registry if you know what the UUID (or whatever it is) of (or assigned to) the interface (it's in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Interfaces). The OP said the card would be connected, so it might not be an issue, but I think it's important to know that. Wouldn't want you to suddenly get blank strings or exceptions and not know why. ;-)