Tuesday, January 29, 2019

How to shutdown, log off and restart the computer with C Programming?

Hello guys i know some of you might not be familiar with the C programming, but this is very basic programming language for programming,and today we are going to learn some source codes that helps to create .EXE file that does some sign out options for you computer, if you are tired of going to start menu and choose the option to shut down the computer, this tutorial is for you, you can simply have a file in desktop that will shut down or restart or log off your computer.  however you have to use compilers to compile this language, i would suggest "Code::Blocks" for a perfect IDE for beginners. If you don't have the software, make sure you do, it is totally free of cost, Click Here . Anyway let's get into the tutorial,

After you have an IDE, you have to type down this source code.

If you want to make a .EXE file to shutdown the system: 

#include<stdio.h>
void main()
{
system("c:\\windows\\System32\\shutdown -s");
}

To restart the computer: 

#include<stdio.h>
void main()
{
system("c:\\windows\\System32\\shutdown -r");
}

To logg off the computer: 

#include<stdio.h>
void main()
{
system("c:\\windows\\System32\\shutdown -l");
}

if you are still confused at how to use the Code::Blocks, i will make another tutorial for that too, but for now, i think this helps you, have a good day guys.

No comments:

Post a Comment