C++ Program to ShutDown & Restart your Computer system (Applicable in Windows Operating System)

Leave a Comment
/* The following C++ program will ask you about the 2 choices of shutting down & restarting your system. After the option is entered the windows system file is executed, letting the system to restart or Shutdown. In this program the delay is 30 Seconds, but you can increase or decrease it as per your choice*/

#include<iostream>
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int main()
{
int c;
cout<<"\nEnter your choice\n";
cout<<"1.Shutdown \n";
cout<<"2.Restart \n";
cin>>c;
switch(c)
{
case 1:cout<<"Your system will be closed after 30 seconds \n\n";
system("c:\\windows\\system32\\shutdown /s /t 30 \n\n");
break;

case 2:cout<<"your system will be restarted in 30 seconds\n\n";
system("c:\\windows\\system32\\shutdown /r /t 30\n\n");
break;

deafault:
cout<<"Invalid Chioce \n\n";
}
getch();
return 0;
}


Note: 
# If you have installed your windows version of other drive, say G:   so you need to change the following c:\\windows\\system32\\shutdown /r /t 30 as g:\\windows\\system32\\shutdown /r /t 30

# If your want to change the system shutdown or restart delay to 45 seconds you need to change the following c:\\windows\\system32\\shutdown /r /t 30 as c:\\windows\\system32\\shutdown /r /t 45.


Screenshot:

C++ Program to ShutDown & Restart your Computer system (Applicable in Windows Operating System)
C++ Program to ShutDown & Restart your Computer system (Applicable in Windows Operating System)

0 comments: