Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- a = nic.EnableStatic(IPAddress=[ip],SubnetMask=[subnetmask])
- b = nic.SetGateways(DefaultIPGateway=[gateway])
- # Set DNS Server list
- c = nic.SetDNSServerSearchOrder(dns)
- d = nic.SetDynamicDNSRegistration(true)
- # These are just for some debugging so that I can see the return codes of the methods
- print(a)
- print(b)
- print(c)
- print(d)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement