-
Notifications
You must be signed in to change notification settings - Fork 0
/
Code.py
129 lines (122 loc) · 6.56 KB
/
Code.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
from PyQt6 import QtCore, QtGui, QtWidgets
import os
class Ui_mainWindow(object):
def setupUi(self, mainWindow):
mainWindow.setObjectName("mainWindow")
mainWindow.setEnabled(True)
mainWindow.setFixedSize(400, 600)
mainWindow.setWindowIcon(QtGui.QIcon('Logo.png'))
font = QtGui.QFont()
font.setBold(False)
font.setWeight(50)
mainWindow.setFont(font)
self.centralwidget = QtWidgets.QWidget(mainWindow)
self.centralwidget.setObjectName("centralwidget")
self.Addr_2 = QtWidgets.QTextEdit(self.centralwidget)
self.Addr_2.setGeometry(QtCore.QRect(10, 120, 381, 31))
font = QtGui.QFont()
font.setPointSize(11)
font.setBold(True)
font.setWeight(75)
self.Addr_2.setFont(font)
self.Addr_2.setObjectName("Addr")
self.Run = QtWidgets.QPushButton(self.centralwidget)
self.Run.setGeometry(QtCore.QRect(280, 250, 111, 31))
self.Run.setObjectName("Run")
self.Log = QtWidgets.QTextBrowser(self.centralwidget)
self.Log.setGeometry(QtCore.QRect(10, 490, 381, 51))
self.Log.setObjectName("Log")
self.descriptionbox = QtWidgets.QLabel(self.centralwidget)
self.descriptionbox.setGeometry(QtCore.QRect(10, 20, 205, 31))
self.descriptionbox.setTextFormat(QtCore.Qt.TextFormat.RichText)
self.descriptionbox.setWordWrap(True)
self.descriptionbox.setOpenExternalLinks(True)
self.descriptionbox.setObjectName("descriptionbox")
self.descriptionbox_3 = QtWidgets.QLabel(self.centralwidget)
self.descriptionbox_3.setGeometry(QtCore.QRect(10, 90, 205, 31))
self.descriptionbox_3.setTextFormat(QtCore.Qt.TextFormat.RichText)
self.descriptionbox_3.setWordWrap(True)
self.descriptionbox_3.setOpenExternalLinks(True)
self.descriptionbox_3.setObjectName("descriptionbox_3")
self.descriptionbox_4 = QtWidgets.QLabel(self.centralwidget)
self.descriptionbox_4.setGeometry(QtCore.QRect(10, 460, 51, 31))
self.descriptionbox_4.setTextFormat(QtCore.Qt.TextFormat.RichText)
self.descriptionbox_4.setWordWrap(True)
self.descriptionbox_4.setOpenExternalLinks(True)
self.descriptionbox_4.setObjectName("descriptionbox_4")
self.descriptionbox_2 = QtWidgets.QLabel(self.centralwidget)
self.descriptionbox_2.setGeometry(QtCore.QRect(0, 240, 191, 61))
self.descriptionbox_2.setTextFormat(QtCore.Qt.TextFormat.RichText)
self.descriptionbox_2.setWordWrap(True)
self.descriptionbox_2.setOpenExternalLinks(True)
self.descriptionbox_2.setObjectName("descriptionbox_2")
self.descriptionbox_5 = QtWidgets.QLabel(self.centralwidget)
self.descriptionbox_5.setGeometry(QtCore.QRect(0, 540, 401, 61))
self.descriptionbox_5.setTextFormat(QtCore.Qt.TextFormat.RichText)
self.descriptionbox_5.setWordWrap(True)
self.descriptionbox_5.setOpenExternalLinks(True)
self.descriptionbox_5.setObjectName("descriptionbox_5")
self.Addr_1 = QtWidgets.QTextEdit(self.centralwidget)
self.Addr_1.setGeometry(QtCore.QRect(10, 50, 381, 31))
font = QtGui.QFont()
font.setPointSize(11)
font.setBold(True)
font.setWeight(75)
self.Addr_1.setFont(font)
self.Addr_1.setObjectName("Addr_2")
self.progressBar = QtWidgets.QProgressBar(self.centralwidget)
self.progressBar.setGeometry(QtCore.QRect(57, 190, 291, 21))
self.progressBar.setProperty("value", 0)
self.progressBar.setObjectName("progressBar")
self.progressBar.setEnabled(False)
mainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(mainWindow)
self.statusbar.setObjectName("statusbar")
mainWindow.setStatusBar(self.statusbar)
self.retranslateUi(mainWindow)
self.Run.released.connect(self.start_app)
QtCore.QMetaObject.connectSlotsByName(mainWindow)
def runner(self, command, mode):
if mode=="cmd":
return os.popen(command).read()
elif mode=="ps":
return os.popen(f"powershell {command}").read()
def start_app(self):
self.Log.clear()
dir = self.Addr_1.toPlainText()
target = self.Addr_2.toPlainText()
self.progressBar.setEnabled(True)
self.Log.append("Started.")
if not os.path.exists(target):
os.makedirs(target)
self.Log.append(self.runner(f"robocopy {dir} {target} /S /E /COPYALL", "cmd"))
self.progressBar.setProperty("value", 25)
self.Log.append(self.runner(f"takeown /f {dir} /r /d y", "cmd"))
self.progressBar.setProperty("value", 50)
self.Log.append(self.runner("TASKKILL /F /IM explorer.exe", "cmd"))
self.progressBar.setProperty("value", 75)
os.system(f"RMDIR /S /Q {dir}")
self.Log.append(self.runner(f"mklink /D {dir} {target}", "cmd"))
self.progressBar.setProperty("value", 100)
self.Log.append(self.runner("start explorer", "cmd"))
self.Log.append("Done!")
self.progressBar.setEnabled(False)
self.Addr_1.clear()
self.Addr_2.clear()
def retranslateUi(self, mainWindow):
_translate = QtCore.QCoreApplication.translate
mainWindow.setWindowTitle(_translate("mainWindow", "Linker!"))
self.Run.setText(_translate("mainWindow", "Run"))
self.descriptionbox.setText(_translate("mainWindow", "<html><head/><body><p><span style=\" font-weight:600; color:#c01c28;\">Directory:</span></p></body></html>"))
self.descriptionbox_3.setText(_translate("mainWindow", "<html><head/><body><p><span style=\" font-weight:600; color:#c01c28;\">Traget:</span></p></body></html>"))
self.descriptionbox_4.setText(_translate("mainWindow", "<html><head/><body><p><span style=\" font-size:12pt; font-weight:600; color:#c01c28;\">Logs:</span></p></body></html>"))
self.descriptionbox_2.setText(_translate("mainWindow", "<html><head/><body><p align=\"center\"><span style=\" font-weight:600; font-style:italic; color:#a51d2d;\">Use At Your OWN Risk!</span></p></body></html>"))
self.descriptionbox_5.setText(_translate("mainWindow", "<html><head/><body><p align=\"center\"><span style=\" font-size:10pt; font-weight:600; font-style:italic; color:#a51d2d;\">Nima Fanniasl - smartnima.com</span></p></body></html>"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
mainWindow = QtWidgets.QMainWindow()
ui = Ui_mainWindow()
ui.setupUi(mainWindow)
mainWindow.show()
sys.exit(app.exec())