Setting DNS using win32com

N

Nacho

I am trying to make a small python application to change DNS servers
in a small LAN.

I am trying this code but I don't manage it to work, I only get the
values removed.

My code is this:

import win32com.client

objWMIService = win32com.client.GetObject("winmgmts:
{impersonationLevel=impersonate}!\\\\" + strComputer + "\\root\
\cimv2")
nicList = objWMIService.ExecQuery("SELECT * FROM
Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")

for nic in nicList:
nic.DNSServerSearchOrder = (u'1.2.3.4', u'2.3.4.5')
nic.SetDNSServerSearchOrder

nic.SetDNSServerSearchOrder returns 0 so it is supposed to have been
done correctly, but no DNS Server is found in the Network Properties.

I don't know what I am doing wrong so any hint or any documentation
about this would be appreciated.

Thank you by now.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

win32 wins settings 2
join a samba domain 10
win32com (VBScript to Python) problem 13
trying to use wmi with asp 2
problem with code (newbie) 4
Get Default printer WMI 2
Using Shell command in ASP.Net 3
exec method WMI 2

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top