如何使windows重新启动与确认?
我得到一些代码,如:private static void StartShutDown(string param)
{
ProcessStartInfo proc = new ProcessStartInfo();
proc.FileName = "cmd";
proc.WindowStyle = ProcessWindowStyle.Hidden;
proc.Arguments = "/C shutdown " + param;
Process.Start(proc);
}
public static void Restart()
{
StartShutDown("-r -t 5");
}
但是我没有"are you shure to restart"之类的确认信息。等等。
MatSnow是对的,你必须这样做:
private static void StartShutDown(string param)
{
if(MessageBox.Show("Confirm shutdown ?","Shutdown ?",MessageBoxButtons.YesNo) == DialogResult.Yes)
{
ProcessStartInfo proc = new ProcessStartInfo();
proc.FileName = "cmd";
proc.WindowStyle = ProcessWindowStyle.Hidden;
proc.Arguments = "/C shutdown " + param;
Process.Start(proc);
}
}
public static void Restart()
{
StartShutDown("-r -t 5");
}