PC IP configuration automatically

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Locked
Gaelds
Messages: 254
Registration: Nov 22, 2015 - 08:37

January 6, 2020 - 9:32 AM

Good morning,
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 delete the "ipconfig /renew" command, the package installs without error, but the DNS settings are not automatically reset.
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.
Locked