c# - Releasing and Renewing your DHCP-based IP Address -
using c# how can release , renew dhcp-based ip address?
at moment using process method use these dos commands:
ipconfig /release
and
ipconfig /renew
is there more managed approach in c# this?
you could use wmi, simpler using system.diagnostics.process
here wmi solution anyway:
managementclass objmc = new managementclass("win32_networkadapterconfiguration"); managementobjectcollection objmoc = objmc.getinstances(); foreach (managementobject objmo in objmoc) { //need determine adapter here kind of if() statement objmo.invokemethod("releasedhcplease", null, null); objmo.invokemethod("renewdhcplease", null, null); }
Comments
Post a Comment