Portfolio

Sunday, September 27, 2015

How to Shutdown and Restart your Computer Using C#?






Making an application to shutdown your computer was fairly easy to my surprise. 
Here's the source code





How To Shutdown and Restart Your Computer Using C#



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;

namespace ShutdownAp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("Shutdown", "/s /t 0");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("Restart", "/r /t 0");
        }
    }
}

No comments:

Post a Comment