-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLockFIlesCommandLineV.py
65 lines (48 loc) · 2.13 KB
/
LockFIlesCommandLineV.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
from tkinter import Tk
import os
from tkinter.constants import YES # from tkinter import Tk for Python 3.x
from tkinter.filedialog import askopenfilename
from rich import print
import rich
import ctypes, os
def isAdmin():
try:
is_admin = (os.getuid() == 0)
except AttributeError:
is_admin = ctypes.windll.shell32.IsUserAnAdmin() != 0
return is_admin
if isAdmin():
print("Program succesfully running as admin, ready to commence (Unlock/Lock)")
else:
print("Program is not running as admin, Please run program as admin next time")
quit()
FirstAsk = input("Do you want to lock or unlock file? (Lock/Unlock)" + ' ')
if FirstAsk == 'Lock':
PathToFIle = askopenfilename() # show an "Open" dialog box and return the path to the selected file
if PathToFIle == "":
print("Restart the script, You selected nothing")
quit()
print("Answer ""Yes"" If you want to")
Asked = input("Are you sure you want to lock " + PathToFIle + ' ')
FormatedPath = str('cacls') + ' ' + PathToFIle + ' ' + str("/P everyone:n")
print(FormatedPath)
if Asked == 'Yes':
print("Opening hidden cmd")
os.system("start /wait cmd /c" + FormatedPath)
else:
print("Please only type Yes If you want to nothing else")
#----------------------------------------------------------------------------------------------------------------------------------------------------
if FirstAsk == 'Unlock':
PathToFIle = askopenfilename() # show an "Open" dialog box and return the path to the selected file
if PathToFIle == "":
print("Restart the script, You selected nothing")
quit()
print("Answer ""Yes"" If you want to")
Asked = input("Are you sure you want to lock " + PathToFIle + ' ')
FormatedPath = str('cacls') + ' ' + PathToFIle + ' ' + str("/P everyone:f")
print(FormatedPath)
if Asked == 'Yes':
print("Opening hidden cmd")
os.system("start /wait cmd /c" + FormatedPath)
else:
print("Please only type Yes If you want to nothing else")