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...

Cool and Best software's that you should have on your New PC.

Hi Guys welcome back to Worldtech360 . This article will be useful for those who dump there PC with lot's of software. As they try to install different type of software on pc,though the software do not match to the system requirements and try to crash or damage their pc.For them i listed the best and commonly used software. Source code Editors: The editors plays a crucial role while you are running a website because it can be used to create templates and many more.It can also be used to write languages like c/c++,java ,basic and many more.keeping this in mind i listed the best software: 1 .Notepad ++ : Notepad++ is a free source code editor.It supports several languages.In one word to say,it is the modification of the Notepad and simple to handle. You can download it by click on this( CLICK HERE ). 2. Text pad: Text pad is a popular source code editor.It can be used  for editing your web pages, or a programming IDE. It is most commonly used by companies t...

8 Important Tips to Protect Your Magento Store from Hacking

Protection of eCommerce and financial websites is necessary because these websites deal with monetary transactions and stand first as a victim in the list of cyber crime. Magento is the most popular eCommerce platform which also comes under threat of hacking by accessing unauthorized logins and other attacks. Magento Platform is rich in security features but security is needed on the admin level to protect it from cyber criminals. Here are some security tips that help you to protect your Magento store and keep your site safe: 1.Admin Path Customization: It is the first step you can take to keep your Magento site safe is to customize the admin path because the normal login pages and admin pages can easily be accessed by just hit and trial methods and it is very easy to navigate to admin page by hackers if the path remains unchanged. With the use of many hacking software available online, it is easy to guess user name and password combinations and these software can guess user n...