-
Notifications
You must be signed in to change notification settings - Fork 0
/
SHUT_DOWN.cpp
72 lines (72 loc) · 1.71 KB
/
SHUT_DOWN.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<sstream>
using namespace std;
int getInput();
int main()
{
int ch, sec, i;
string strOne, strTwo;
char str_One[50], str_Two[10];
ostringstream intToStr;
cout<<"1. Shutdown Computer\n";
cout<<"2. Restart Computer\n";
cout<<"3. Exit\n";
cout<<"Enter Your Choice: ";
cin>>ch;
if(ch==1 || ch==2)
{
cout<<"Enter Number of Seconds: ";
cin>>sec;
intToStr<<sec;
strTwo = intToStr.str();
}
switch(ch)
{
case 1:
strOne = "C:\\Windows\\System32\\shutdown /s /t ";
i=0;
while(strOne[i])
{
str_One[i] = strOne[i];
i++;
}
str_One[i] = '\0';
i=0;
while(strTwo[i])
{
str_Two[i] = strTwo[i];
i++;
}
str_Two[i] = '\0';
strcat(str_One, str_Two);
system(str_One);
break;
case 2:
strOne = "C:\\Windows\\System32\\shutdown /r /t ";
i=0;
while(strOne[i])
{
str_One[i] = strOne[i];
i++;
}
str_One[i] = '\0';
i=0;
while(strTwo[i])
{
str_Two[i] = strTwo[i];
i++;
}
str_Two[i] = '\0';
strcat(str_One, str_Two);
system(str_One);
break;
case 3:
return 0;
default:
cout<<"\nWrong Choice!";
return 0;
}
return 0;
}