private void closeSystem()
{
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = "shutdown", // 指定命令为shutdown
Arguments = "/s /t 0", // /s 参数表示关闭,/t 后跟时间,0表示立即
UseShellExecute = true, // 需要启用Shell执行
CreateNoWindow = false // 不创建新窗口
};
try
{
// 启动进程
Process.Start(startInfo);
Application.Exit(); // 如果需要,可以退出应用程序
}
catch (Exception ex)
{
MessageBox.Show("关机失败: " + ex.Message);
}
}