M MingChih Tsai Dec 6, 2005 #1 Hi there, How should I do if I want to release/renew IP in C# ? Thanks!! Best regards, Paul
V ViRi Dec 6, 2005 #2 Try This: private void RenewIpConfig() { System.Diagnostics.Process p = new System.Diagnostics.Process(); System.IO.StreamWriter sw; System.IO.StreamReader sr; System.IO.StreamReader err; System.Diagnostics.ProcessStartInfo psI = new System.Diagnostics.ProcessStartInfo("cmd"); psI.UseShellExecute = false; psI.RedirectStandardInput = true; psI.RedirectStandardOutput = true; psI.RedirectStandardError = true; psI.CreateNoWindow = true; p.StartInfo = psI; p.Start(); sw = p.StandardInput; sr = p.StandardOutput; err = p.StandardError; sw.AutoFlush = true; sw.WriteLine("ipconfig /renew"); sw.Close(); System.Diagnostics.Debug.WriteLine("Returned Info: " + sr.ReadToEnd()); System.Diagnostics.Debug.WriteLine("Errors: " + err.ReadToEnd()); }
Try This: private void RenewIpConfig() { System.Diagnostics.Process p = new System.Diagnostics.Process(); System.IO.StreamWriter sw; System.IO.StreamReader sr; System.IO.StreamReader err; System.Diagnostics.ProcessStartInfo psI = new System.Diagnostics.ProcessStartInfo("cmd"); psI.UseShellExecute = false; psI.RedirectStandardInput = true; psI.RedirectStandardOutput = true; psI.RedirectStandardError = true; psI.CreateNoWindow = true; p.StartInfo = psI; p.Start(); sw = p.StandardInput; sr = p.StandardOutput; err = p.StandardError; sw.AutoFlush = true; sw.WriteLine("ipconfig /renew"); sw.Close(); System.Diagnostics.Debug.WriteLine("Returned Info: " + sr.ReadToEnd()); System.Diagnostics.Debug.WriteLine("Errors: " + err.ReadToEnd()); }
I Ignacio Machin \( .NET/ C# MVP \) Dec 6, 2005 #3 Hi, I think that opennetcf.org has some code for this, check it out cheers,