[python-win32] Calling Win32_NetworkAdapterConfiguration routines from WMI com object
Rohit Kumar
rohit.kumar at chelsio.com
Sat Nov 26 11:20:14 CET 2011
Thanks in advance for help. I am trying to set the ip address
of a network interface using win32com module and unable to do
so. I have tried searching a lot but wasn't able to get a
answer for the issue. Here is the code I am running :
import win32com.client
obj = win32com.client.Dispatch("WbemScripting.SWbemLocator")
wmobj = obj.ConnectServer("localhost","root\cimv2")
nobj = wmobj.ExecQuery("Select * from Win32_NetworkAdapterConfiguration")
for n in nobj:
print n.Caption
n.SetMTU('9000')
When I run this code it errors out with following error :
Traceback (most recent call last):
File "", line 3, in n.SetMTU('9000')
File"C:\Python27\lib\site-packages\win32com\client\dynamic.py",
line 505, in getattr ret =
self.oleobj.Invoke(retEntry.dispid,0,invoke_type,1)
com_error: (-2147352567, 'Exception occurred.',
(0, u'SWbemObjectEx', u'Invalid method ',None, 0, -2147217362), None)
I did some more debugging and found that I can access any variables
of Win32Networking class but whenever I try to call any method of
the class it returns me this same error.
More information about the python-win32
mailing list