-
Notifications
You must be signed in to change notification settings - Fork 0
/
powerwin.pas
74 lines (63 loc) · 1.87 KB
/
powerwin.pas
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
73
74
program powerWIN;
uses
SysUtils, Process;
(* BANNER *)
function banner() :string;
begin
writeln('');
writeln(' -------------------- powerWIN ---------------------');
writeln('| |');
writeln('| example : powerwin.exe [OPTIONS.....] |');
writeln('| OPTIONS : |');
writeln('| [ -h | --help ] .......... about this tool |');
writeln('| [ -slp | --sleep ] ....... sleep option |');
writeln('| [ -rst | --restart ] ..... restart option |');
writeln('| [ -shd | --shutdown ] .... shutdown option |');
writeln('| |');
writeln(' --------------------------------------------------- ');
banner:='';
end;
(* SLEEP *)
function sleep() :string;
begin
ExecuteProcess('cmd','/c rundll32.exe powrprof.dll, SetSuspendState Sleep');
sleep:='';
end;
(* RESTART *)
function restart() :string;
begin
ExecuteProcess('cmd','/c shutdown /r');
restart:='';
end;
(* SHUTDOWN *)
function shutdown() :string;
begin
ExecuteProcess('cmd','/c shutdown /s');
shutdown:='';
end;
var
OPTION :string;
begin
OPTION := ParamStr(1);
(* OPTIONS *)
if ( OPTION = '-h' ) or ( OPTION = '--help' ) then
begin
banner();
end
else if ( OPTION = '-slp' ) or ( OPTION = '--sleep' ) then
begin
sleep();
end
else if ( OPTION = '-rst' ) or ( OPTION = '--restart' ) then
begin
restart();
end
else if ( OPTION = '-shd' ) or ( OPTION = '--shutdown' ) then
begin
shutdown();
end
else
begin
banner();
end;
end.