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

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

Top 10 Best Anime series you should watch.

Anime is a Japanese film which is far more advanced than the normal cartoon which we watch regularly.As the demand for Anime is increasing day by day,author are trying to create new anime series.Keeping in this mind,in this post i am gonna list out some of the best anime series and make the readers to watch top anime series. Top Anime List: 1. One Piece. 2. Naruto Shippuden. 3. Fairy Tail. 4. Bleach. 5. Dragon ball Z. 6. Dragon ball GT. 7. Hunter x Hunter(2011). 8. Ao no exorcist. 9. Death note. 10. Naruto. Top Cool Notepad tricks. That's it friends i hope you like this article and if you know other anime which are best,then just comment the name in the comment section so that we will add it to the post and have a nice day.

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