From a91c77bf923890a2800aef9509a348ae5a0d4fdd Mon Sep 17 00:00:00 2001 From: chenxudong Date: Mon, 16 Jun 2025 15:20:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=8D=B8=E8=BD=BD=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Uninstall.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/Uninstall.py diff --git a/src/Uninstall.py b/src/Uninstall.py new file mode 100644 index 0000000..a5fae4a --- /dev/null +++ b/src/Uninstall.py @@ -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("卸载取消")