[Tutor] WMI

Spencer Parker inthefridge at gmail.com
Tue Sep 16 21:36:18 CEST 2008


This is the code that I currently have:

import wmi

con =wmi.WMI()
ip = "10.1.10.20"
subnet = "255.255.255.0"
gateway = "10.1.10.1"

wql = "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled =
TRUE"

for adapter in con.query(wql):
    ReturnValue = adapter.EnableStatic(IPAddress=ip, SubnetMask=subnet)

On Tue, Sep 16, 2008 at 1:01 PM, Tim Golden <mail at timgolden.me.uk> wrote:

> Spencer Parker wrote:
>
>> Has anyone here had any experience with WMI extensions in Python?
>>
>> I am trying to remotely change the IP, Subnet, and gateway of a windows
>> machine, but I cannot figure out what it needs to change this.
>>
>
> You'll need the Win32_NetworkAdapterConfiguration class and,
> for ease, the wmi module from here:
>
> http://timgolden.me.uk/python/wmi.html
>
> <code>
> import wmi
>
> c = wmi.WMI ()
>
> for i in c.Win32_NetworkAdapterConfiguration (IPEnabled=True):
>  print i
>
> You'll need things like the .SetGateways method. You can see
> all the methods thus:
>
> print "\n".join (i.methods)
>
> and if you print any of them, it will show its signature:
>
> print i.SetGateways
>
> </code>
>
>
> HTH
> TJG
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
Spencer Parker
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080916/0d7ea1f7/attachment.htm>


More information about the Tutor mailing list