完成卸载相关功能
This commit is contained in:
parent
5529700151
commit
a91c77bf92
|
|
@ -0,0 +1,41 @@
|
|||
import shutil
|
||||
import subprocess
|
||||
import time
|
||||
import tkinter as tk
|
||||
from tkinter import messagebox
|
||||
from loguru import logger
|
||||
|
||||
|
||||
def delete_service(service_name):
|
||||
stop_command = ["sc", "stop", service_name]
|
||||
delete_command = ["sc", "delete", service_name]
|
||||
subprocess.run(stop_command, capture_output=True, text=True)
|
||||
subprocess.run(delete_command, capture_output=True, text=True)
|
||||
time.sleep(5)
|
||||
pass
|
||||
|
||||
|
||||
def start_uninstall():
|
||||
logger.info("开始清理服务")
|
||||
service_names = {'ComacDatabase', 'ComacMariaDB'}
|
||||
for service in service_names:
|
||||
delete_service(service)
|
||||
logger.info("开始清理数据")
|
||||
dirs = [rf'D:\database\logs', rf'D:\database\mariadb', rf'D:\database\jdk']
|
||||
for dir in dirs:
|
||||
shutil.rmtree(dir)
|
||||
logger.info('清理完成,10秒钟后自动退出')
|
||||
time.sleep(10)
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# 创建主窗口(但不显示)
|
||||
root = tk.Tk()
|
||||
root.withdraw() # 隐藏主窗口
|
||||
# 弹出确认对话框
|
||||
response = messagebox.askyesno("确认卸载", "确定卸载?")
|
||||
if response:
|
||||
start_uninstall()
|
||||
else:
|
||||
logger.info("卸载取消")
|
||||
Loading…
Reference in New Issue