Skip to main content

Shutdown your PC using C program.

Hi guys all of we know how to shutdown the PC using batch file or by normal method.But have you ever tried to shutdown your PC using C program.If not in this tutorial i am gonna teach you how to shutdown your  PC by writing a simple c program.so lets see how to do this.
Shutdown your PC using C program.

Steps:

1.Open any c program compiler and copy the below code.

Code to shutdown the PC:

For windows 7:

#include <stdio.h>
#include <stdlib.h>
#include<conio.h>//optional
main()
{
   char ch;
   printf("Do you want to shutdown your system yes or no\n");
   scanf("%c",&ch);
   if (ch == 'Y' || ch == 'y')
      system("C:\\WINDOWS\\System32\\shutdown /s");// s-shutdown r-restart l-logoff h-hibernate
  getch();//you can use return 0; instead of getch();
 
}
Note: 
  • S-Shutdown.
  • r-Restart.
  • l-Log off.
  • h-Hibernate.
It takes 30 seconds to shutdown,But if you want to shutdown immediately use shutdown /s/t 0 instead of shutdown /s in windows 7.Here /t 0 means shutdown after zero seconds.

For windows XP:

#include <stdio.h>
#include <stdlib.h>
#include<conio.h>
main()
{
   char ch;
   clrscr();
   printf("Do you want to shutdown your system yes or no\n");
   scanf("%c",&ch);
   if (ch == 'Y' || ch == 'y')
      system("C:\\WINDOWS\\System32\\shutdown -s");// s-shutdown r-restart l-logoff  h-hibernate   getch();//you can use return 0; instead of getch();   
}
2.Finish. 
That's it friends i hope you enjoyed the article and if you have any ideas or any queries regaridng any topic feel free to ask us through comments and have a nice day.

Comments

Popular posts from this blog

How to make an Installation file(setup file) using Iexpress.

Hi guys welcome to worldtech360. In this tutorial or article I  am going to show you how to create an installation file(setup file) for the .EXE file which you have created using an inbuilt option in windows 7 named ‘ iexpress ’. So let’s see how to do this. Note: You can also create an installation file for .bat file files or .VBS files or any other files which are executable. Steps: 1. Choose an .EXE file or any other file for which you want to create a setup file or installation file. In this I am going to use .VBS file 2. Open Run and type “ iexpress ” or “ iexpress.exe ” and hit enter. 3. After hitting enter, iexpress wizard window will popup. On the screen you will see two options i.e. “ create new self-extracting directive file ” and the other is “ open existing self-extracting directive file ”. I recommend you to choose the first option as you are going to create a self-extracting file and click next. 4. In the next window select “ Extract files on...

How to install Backtrack 5 R3 on Oracle VM virtual box

Hi guys in this tutorial i am gonna show you how to install Backtrack 5r3 using virtual box.This tutorial is only for Educational purpose,Don't try to use it in a wrong way.Before going into the discussion let see what exactly backtrack means?Backtrack is an operating system which is developed especially for hackers and other security professionals.Mostly if we want to hack a wifi password i.e WEP or WPA or if we want to do phishing we need certain tools to do it.But Backtrack reduces this burden as it contains a bag full of hacking software's like gerex,Social engineering tools and many more.So lets install backtrack 5 r3 using virtual box. Steps:  Requirements: Backtrack( CLICK HERE ). Virtualbox( CLICK HERE ). 1.Install the Virtual box and open it. 2.Now we see a screen like below. 3.Click on New button and a window will up asking to type the name,Type and version.Select the type as 'linux' and version as 'oracle' as shown below and hit next...

How to Make Invincible folders using Charmap.

Every one of us have our confidential data residing on our desk and we try to be protect it by using various Folder locks (Paid and free version).But have you ever tried to protect it without using any software’s, if not in this tutorial i am gonna show you how to make a folder invincible and it works perfectly. This post will be useful for those who are not in a stage to buy the folder lock software’s. So let’s see how to do this. You can also check : How to lock a folder using notepad   Video Tutorial: Steps: 1. Open Run and type " charmap "(Run with Administrator rights). 2. Browse to the blank character in it as shown below and click on select and Copy the selected character. 3. Now select the folder which you want to make invincible and click F2 to rename it. Now paste the character which you have selected in the CHARMAP and press enter. Now you will see a folder without a name. 4. Right click on the nameless folder and click on properties and br...