Advertisement
JamesYeoman

Untitled

Sep 28th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. import wmi
  2.  
  3. nic_configs = wmi.WMI('').Win32_NetworkAdapterConfiguration(IPEnabled=True)
  4.  
  5. # First network adaptor
  6. nic = nic_configs[0]
  7.  
  8. # IP address, subnetmask and gateway values should be unicode objects
  9. ip = u'192.168.0.151'
  10. subnetmask = u'255.255.255.0'
  11. gateway = u'192.168.0.1'
  12. dns = u'192.168.0.1'
  13.  
  14. # Set IP address, subnetmask and default gateway
  15. a = nic.EnableStatic(IPAddress=[ip],SubnetMask=[subnetmask])
  16. b = nic.SetGateways(DefaultIPGateway=[gateway])
  17.  
  18. # Set DNS Server list
  19. c = nic.SetDNSServerSearchOrder(dns)
  20. d = nic.SetDynamicDNSRegistration(true)
  21.  
  22. # These are just for some debugging so that I can see the return codes of the methods
  23. print(a)
  24. print(b)
  25. print(c)
  26. print(d)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement