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

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

How to Check & Stop Keyloggers in Your PC/Laptop

Do you use public computers, Cyber-Cafe or PC? Then you must know about keyloggers. Keylogger is a small software that can be installed or hidden in your pc without your knowledge. That record user activity (keystroke) and make a log file. It is used by hackers or in companies in surveillance employees’ systems. It can capture your email login details, every click, visited website URLs and even your confidential data like, your bank account number, passwords, credit/ debit card details etc. Keylogger transmit your information to third parties and you can be a victim of an internet scam or frauds. It would be better to understand and protected you from them. In this post I will tell you how to get rid of keyloggers in easy steps. First, we should know how keylogger can be installed in your PC. How keylogger could attack your PC: By using infected pendrives/hard drives. While Downloading torrents, cracks, keygens from internet. Installed by person who wants to track you pc. ...