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

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -