C++ Program To Restart Windows Desktop

The execution of a computer program controls every digital device you use. Programs are a set of instructions given to a system for performing specific operations. Also, programs help the hardware and software to interact with each other. And with the help of these programs, you can also control your desktop environment. If you know basic programming, then giving instructions to your desktop with the use of pre-written programs might make you seem more extraordinary in front of your friends. So today, we’re going to start with a straightforward C++ Program To Restart Windows Desktop.

 

What’s The Approach?

 

  • Firstly we are going to include the stdlib.h header file.

 

  • Now, we’ll take the input in a variable, with y as the Restart choice.

 

  • If the user Enters any other key as the option, we’ll  return .

 

  • However, if the user selects y as the option, we’ll execute the command, ssystem("C:\\Windows\\System32\\shutdown /r /t 0");

 

Also Read: Implement Radix Sort Using C++

 

C++ Program To Restart Windows Desktop

 

#include <stdio.h>
#include <stdlib.h>

int main()
{
  char choice;
  printf("Press y to Restart Or Any Other Key To Exit");
    scanf("%s",&choice);
  if(choice == 'y')
  {
    system("C:\\Windows\\System32\\shutdown /r /t 0");
  }
  else {
return 0;
  }
}

 

Ethix

I'm a coding geek interested in cyberspace who loves to write and read

Leave a Reply

Your email address will not be published. Required fields are marked *