Shutdown and Restart Computer in C

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Shutdown and Restart computer in C# ( C

Sharp )
Actualy the program to shutdown or restrart on a computer using C# there are two ways, namely
using the help command prompt and the second pure script of the language itself dotNet. For this
post will be explained and also give examples of haow making project for shutdown or do restart on
a computer using the help command promt, so that programers are required to at least know the
basic function from command promt itselt.
Before you learn more abaout the program that will be made to perform on a computer shutdown
or restrart please read the firs article to run the command prompt in C#. This will graetly help in
understanding this materi. Because the concept is almost similar to way programs run command
prompt such a change. Now beginning its work on the project . As usual for the fitst step please
prepare an empty project an empty project please click on the file after the new project dialog
box appears please use the project name project name in box, there are no specific rules in writing
the name of the project. For the next step please follow the intstruction below
Step 1 : Add two buttons on form1 in the project has been provided previously, organize and
structure such that it looks loke in the picture below

langlah 2 : Add the following code in C# libraries.


using System.Diagnostics;
langkah 3: Double click on button (labeled shutdown) for raising the event click on the button, add
the following source code
Process.Start("shutdown.exe", "/s /t 00 /f");
langkah 4 : Double click on button2(labeled restart) for raising the event click on the button, add
the following source code
Process.Start("shutdown.exe", "/r /t 00 /f");
langkah
5:
Done.
The
program
finished
create.
If the above steps are followed and done correctly the program when run will be show labeled
button shutdown and restart. If the user clicks on the shutdown button, the the computer will be
shutdown by program whereas if the user presses the button then the computer will restart in
restart
by
the
program
to more understand this materi please download the example program here. And also download the
project
of here

Clue download : click the link download above, after which it will apear
adf.ly pages, wait several second until the top right corner it show "skip ad", click the button, after
which it will appear ziddu page, please click on the download button which appears on page ziddu
NB : All of program in this tutorial write using the IDE Visual Studio 2010. with the target framework
3.5

You might also like