I'd like to be able to automatically reset the network settings on my Windows 7 and Windows 10 PCs, but the package I'm using isn't installing correctly. The IP address is set to automatic, but the old DNS settings remain manual (even after a reboot).
Here is the setup.py file:
Code: Select all
#!/usr/bin/python
# -*- coding: utf-8 -*-
from setuphelpers import *
import wmi
import socket
uninstallkey = []
def install():
try:
nic_configs = wmi.WMI().Win32_NetworkAdapterConfiguration(IPEnabled=True)
if not nic_configs:
raise Exception
except Exception:
print u"No network interface found. Exiting gracefully."
exit(1)
for nic in nic_configs:
print u"Please wait..."
print u"Using DHCP on interface '" + nic.description + "'"
nic.EnableDHCP()
#dnsservers = ['172.16.80.13','208.67.222.222']
#nic.SetDNSServerSearchOrder(dnsservers)
#nic.SetDynamicDNSRegistration()
nic.SetDynamicDNSRegistration(FullDNSRegistrationEnabled=1)
run(u'ipconfig /renew', timeout=45)Here are the installation logs from the console:
Code: Select all
Please wait...Using DHCP on interface 'Realtek PCIe GBE Family Controller'Traceback (most recent call last):
File "C:\wapt\common.py", line 3846, in install_wapt
exitstatus = setup.install()
File "c:\windows\temp\waptcnpcef\setup.py", line 22, in install
File "C:\wapt\common.py", line 3625, in run
return ensure_unicode(setuphelpers.run(*arg,pidlist=self.pidlist,**args))
File "C:\wapt\setuphelpers.py", line 1046, in run
raise TimeoutExpired(cmd,''.join(output),timeout)
TimeoutExpired: Command 'ipconfig /renew' timed out after 15 seconds with output ''\r\nConfiguration IP de Windows\r\n\r\n''
TimeoutExpired: Command 'ipconfig /renew' timed out after 15 seconds with output ''\r\nConfiguration IP de Windows\r\n\r\n''
If I replace the nic.SetDynamicDNSRegistration() command with nic.SetDNSServerSearchOrder(['172.16.80.13','172.16.80.14']), the DNS is indeed modified.
The command nic.SetDynamicDNSRegistration(FullDNSRegistrationEnabled=1) does not appear to work either.
