Reputation: 665
When I try to do this
SetDynamicDNSRegistration(True)
It returns '68' which I have looked up on the MSDN WMI page and it means "Invalid Input Parameter".
Full Script
import wmi
nic_configs = wmi.WMI('').Win32_NetworkAdapterConfiguration(IPEnabled=True)
# First network adaptor
nic = nic_configs[0]
# IP address, subnetmask and gateway values should be unicode objects
ip = u'192.168.0.151'
subnetmask = u'255.255.255.0'
gateway = u'192.168.0.1'
dns = u'192.168.0.1'
# Set IP address, subnetmask and default gateway
# Note: EnableStatic() and SetGateways() methods require *lists* of values to be passed
a = nic.EnableStatic(IPAddress=[ip],SubnetMask=[subnetmask])
b = nic.SetGateways(DefaultIPGateway=[gateway])
c = nic.SetDNSServerSearchOrder([dns])
d = nic.SetDynamicDNSRegistration(True)
print(a)
print(b)
print(c)
print(d)
What is wrong? I'm sure "True" is the right Python syntax for the boolean TRUE... I don't even know anymore...
Upvotes: 1
Views: 1834
Reputation: 552
Rather than a Python boolean, use its corresponding boolean integer. So instead of
nic.SetDynamicDNSRegistration(True)
use
nic.SetDynamicDNSRegistration(FullDNSRegistrationEnabled=1)
Upvotes: 1