C++ Program to perform system shutdown and restart (Windows) [DEVCPP/GCC]

SYSTEM

This function invokes the command processor to execute a command.

PROGRAM

//Program to perform system shutdown and restart in Windows OS

#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{
        int n;
        char ch;

        cout<<"\n****MENU****\n";

        cout<<"\n1. SHUTDOWN";
        cout<<"\n2. RESTART";
        cout<<"\n3. EXIT";
     
        cout<<"\n\nENTER YOUR CHOICE: ";
        cin>>n;

        switch(n)
        {
                case 1:
                {
                        system("C:\\Windows\\System32\\Shutdown /s /t 60");
                        cout<<"\nSYSTEM WILL SHUT DOWN IN 1 MINUTE!";

                        cout<<"\n\nDO YOU WANT TO ABORT SHUTDOWN(Y/N)?";
                        cin>>ch;

                        if(ch=='y' || ch=='Y')
                        {
                                system("C:\\Windows\\System32\\Shutdown /a");
                                cout<<"\nSYSTEM SHUT DOWN IS ABORTED!";
                        }

                        break;
                }

                case 2:
                {
                        cout<<"\nSYSTEM WILL RESTART IN 1 MINUTE!";
                        system("C:\\Windows\\System32\\Shutdown /r /t 60");

                        cout<<"\n\nDO YOU WANT TO ABORT RESTART(Y/N)?";
                        cin>>ch;

                        if(ch=='y' || ch=='Y')
                        {
                                system("C:\\Windows\\System32\\Shutdown /a");
                                cout<<"\nSYSTEM RESTART IS ABORTED!";
                        }

                        break;
               }

                case 3:
                {
                       exit(0);
                }

                default:
                {
                        cout<<"\nWRONG CHOICE!";
                        break;
                }
        }

        return 0;
}

OUTPUT

C++ Program to perform system shutdown and restart with outputC++ Program to perform system shutdown and restart with output



Share this

Related Posts

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
:-?
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
$-)
(y)
(f)
x-)
(k)
(h)
cheer

FIND US ON FACEBOOK!