Reputation: 1497
I am running a C# Console Application on AWS EC2 instance with Ubuntu. I want to restart the computer from my Application using C#. Is there is any way that I can execute sudo reboot
from C#?
Thanks in advance.
Upvotes: 0
Views: 2346
Reputation: 1497
It works using the below code.
Process process = new Process();
process.StartInfo.FileName = "/usr/bin/sudo";
process.StartInfo.Arguments = "/sbin/shutdown -r now";
process.Start();
Upvotes: 2