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:
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 routine of the class it returns me this same error.