Click here to Skip to main content
15,918,742 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

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?
 
Share this answer
 
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!
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900