在c#中重启计算机 [英] Restart computer in c#
本文介绍了在c#中重启计算机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好。
这是我的代码:
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName =cmd.exe;
startInfo.Arguments = string.Format(@shutdown -r -m \\ {0},txtIP.Text);
Process.Start(startInfo);
我想通过此代码重新启动计算机,但我的项目无法运行。
谢谢
Hi all.
this is my Code :
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "cmd.exe";
startInfo.Arguments = string.Format(@"shutdown -r -m \\{0}", txtIP.Text);
Process.Start(startInfo );
I want to restart computer by this code but my project can not be run .
thanks
推荐答案
您可能希望以管理员身份运行此程序。
除此之外,我没有看到任何重大问题。
您是否面临运行此代码的某种问题?
You may want to running this program as administrator.
Other than that, I don't see any major issues.
Are you facing some kind of issue running this code?
为什么要使用命令?关机是一个自己的过程。查看更多信息:
关闭,重新启动,注销或使用C#锁定计算机 [ ^ ]
祝你好运!
Why use command? shutdown is a process of its own. Check this out for more info:
Shut Down, Restart, Log off or Lock your computer in C#[^]
Good luck!
以下链接可能对您有帮助:
------------------------- -------------
1> 关闭,重启,注销或锁定您的C#中的计算机 [ ^ ]
2> http://stackoverflow.com/问题/ 15955084 / how-do-i-restart-computer-using-c-sharp-on-ec2-ubuntu-server [ ^ ]
Following link may Helpful to you :
--------------------------------------
1> Shut Down, Restart, Log off or Lock your computer in C#[^]
2> http://stackoverflow.com/questions/15955084/how-do-i-restart-computer-using-c-sharp-on-ec2-ubuntu-server[^]
这篇关于在c#中重启计算机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文