-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.py
287 lines (210 loc) · 5.88 KB
/
functions.py
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
import os
import webbrowser
# import disk
def cleanup() -> None:
"""
This function opens the Windows System Cleanup tool (cleanmgr.exe).
Parameters:
None
Returns:
None
Raises:
None
Example:
To open the System Cleanup tool, simply call the cleanup() function:
```python
cleanup()
```
This will start the System Cleanup tool, allowing the user to clean up unnecessary files and optimize their system.
"""
os.startfile('C:\\Windows\\System32\\cleanmgr.exe')
def ctrl() -> None:
"""
This function opens the Computer Management console.
Parameters:
None
Returns:
None
Raises:
None
This function uses the os module's startfile function to open the 'compmgmt.msc' file located in the 'C:\\WINDOWS\\System32' directory.
Example:
>>> ctrl()
"""
path = 'C:\\WINDOWS\\System32\\compmgmt.msc'
os.startfile(os.path.join(path))
def defrag() -> None:
"""
This function opens the Windows Disk Defragmenter tool.
Parameters:
None
Returns:
None
Raises:
None
Example:
>>> defrag()
"""
os.startfile('C:\\Windows\\System32\\dfrgui.exe')
def sys_info() -> None:
"""
This function opens the System Information window using the 'msinfo32.exe' executable.
Parameters:
None
Returns:
None
Raises:
None
Example:
>>> sys_info()
"""
path = 'C:\\WINDOWS\\System32\\msinfo32.exe'
os.startfile(os.path.join(path))
def add_rem() -> None:
"""
This function opens the 'Add or Remove Programs' window in Windows.
Parameters:
None
Returns:
None
Raises:
None
Example:
>>> add_rem()
"""
path = 'C:\\WINDOWS\\System32\\appwiz.cpl'
os.startfile(os.path.join(path))
def win() -> None:
"""
This function opens the Windows Information dialog.
Parameters:
None
Returns:
None
Raises:
None
Example:
>>> win()
"""
path = 'C:\\WINDOWS\\system32\\winver.exe'
os.startfile(os.path.join(path))
def restore() -> None:
"""
This function opens the System Restore dialog box.
Parameters:
None
Returns:
None
Raises:
None
Example:
>>> restore()
"""
os.startfile('C:\\Windows\\System32\\rstrui.exe')
def web() -> None:
webbrowser.open('https://www.techsaralk.epizy.com/')
def github() -> None:
webbrowser.open('https://github.com/DasunNethsara-04')
def telegram() -> None:
webbrowser.open('https://t.me/techsara_lk')
def youtube() -> None:
webbrowser.open('https://www.youtube.com/channel/UCpWe6k8GxYuLmlzlvX7VBRg')
def shutdown() -> None:
"""
This function is used to initiate a system shutdown.
Parameters:
None
Returns:
None
Raises:
This function does not raise any exceptions.
Example:
To initiate a system shutdown, simply call the `shutdown()` function.
```python
shutdown()
```
This will execute the `shutdown.exe` command with the `-s` (shutdown) and `-t 00` (immediate) options.
"""
os.system('shutdown.exe -s -t 00')
def restart() -> None:
"""
This function initiates a restart of the system. It uses the 'shutdown.exe' command-line tool to perform the restart operation. The '-r' parameter specifies that a restart should be performed, and the '-t 00' parameter sets the time delay before the restart to zero seconds.
Parameters:
None
Returns:
None
Raises:
This function does not raise any exceptions.
Example:
>>> restart()
"""
os.system('shutdown.exe -r -t 00')
def hibernate() -> None:
"""
This function initiates the system hibernation process. It does this by calling the 'rundll32.exe powrprof.dll, SetSuspendState' function with the appropriate parameters.
Parameters:
No parameters are required for this function.
Return value:
This function does not return any value. It initiates the hibernation process and then exits.
Raises:
This function does not raise any exceptions. However, if the 'rundll32.exe powrprof.dll, SetSuspendState' function fails to execute for any reason, the system hibernation process will not be initiated.
Example:
To initiate the system hibernation process, simply call the 'hibernate' function:
```python
hibernate()
```
"""
os.system('rundll32.exe powrprof.dll, SetSuspendState')
def lock() -> None:
"""
This function is used to lock the system. It initiates the system locking process by invoking the appropriate Windows API function.
Parameters:
None
Returns:
None
Raises:
This function does not raise any exceptions.
Usage:
To lock the system, simply call the `lock()` function.
Example:
```python
from pc_info import lock
def main():
# Perform some tasks
# ...
# Lock the system
lock()
if __name__ == "__main__":
main()
```
"""
os.system('rundll32.exe user32.dll, LockWorkStation')
def log_off() -> None:
"""
This function initiates the system shutdown process. It uses the 'shutdown.exe' command-line tool to execute the 'l' (log off) option.
Parameters:
No parameters are required for this function.
Returns:
This function does not return any value.
Raises:
This function does not raise any exceptions.
Usage:
To initiate the system shutdown process, simply call the 'log_off' function.
Example:
```python
from pc_info import log_off
# Call the log_off function to initiate the system shutdown process.
log_off()
```
"""
os.system('shutdown.exe -l')
# dis = ''
# def disk_part():
# global lst, dis
# for i in psutil.disk_partitions():
# if i[2] == "":
# continue
# drive, percent = i[0], float(psutil.disk_usage(i[0]).percent)
# free = round(100 - percent, 2)
# dis = Label(frame, text=f'{drive}\t\t{percent}%\t\t{free}%', font='arial 18', fg='green', bg=bgcolor)
# dis.pack(pady=10)