private bool Reboot(string ip)
{
bool isSuccess = false;
System.Diagnostics.Process p = new System.Diagnostics.Process();
try
{
panel1.Visible = true;
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.StandardInput.WriteLine("ping -n 1 " + ip);
p.StandardInput.WriteLine("shutdown -r -f -m " + strIp.Trim() + " -t 0");
p.StandardInput.WriteLine("exit");
string result = "";
result = mp.StandardOutput.ReadToEnd();
if (result.IndexOf("Request timed out") > 0)
{
result = "不能Ping通:" + ip;
}
else
{
result = "";
}
isSuccess = true;
}
catch
{
isSuccess = false;
}
finally
{
p.Dispose();
}
return isSuccess;
}