C# 获取IPCONFIG 返回值
/// <summary>/// 获取IPCONFIG返回值
/// </summary>
/// <returns>返回 IPCONFIG输出</returns>
public static string GetIPConfigReturns()
{
string version = System.Environment.OSVersion.VersionString;
if (version.Contains("Windows"))
{
//调用ipconfig ,并传入参数: /all
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("ipconfig", "/all");
psi.CreateNoWindow = true; //若为false,则会出现cmd的黑窗体
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;
System.Diagnostics.Process p = System.Diagnostics.Process.Start(psi);
return p.StandardOutput.ReadToEnd();
}
return string.Empty;
}
转自:http://www.cnblogs.com/Ren_Lei/archive/2010/08/07/1794576.html
页:
[1]