navicat16 试用期到期
navicat无限重置14天方法-windows_mob604756ebed9f的技术博客_51CTO博客体验Navicat Premium 16,无限重置试用14天方法(附源码)代
navicat无限重置14天方法-windows_mob604756ebed9f的技术博客_51CTO博客体验Navicat Premium 16,无限重置试用14天方法(附源码)代码修改法代码(python)
import winregnimport osnimport timenfrom collections import dequenfrom typing import Anyn n n# rootnHKEY_CURRENT_USER = winreg.HKEY_CURRENT_USERn n# key pathnPREMIUM_PATH = r'SoftwarePremiumSoft'nCLSID_PATH = r'SoftwareClassesCLSID'n n ndef get_sub_keys(root: Any, reg_path: str) -> list:n """This function will retrieve a list of sub-keys under the pathn of `root` + `reg_path`.n n Args:n root(Any): Root registry.n reg_path(str): The relative specific path under the root registry.n n Returns:n The list of sub-keys.n """n key_result = winreg.OpenKeyEx(root, reg_path)n i: int = 0n sub_keys_list: list = list()n n while True:n try:n sub_keys = winreg.EnumKey(key_result, i)n sub_keys_list.append(sub_keys)n i += 1n except Exception as e:n breakn n return sub_keys_listn n ndef get_all_keys(root: Any, key_path: str) -> list:n """Get the list of absolute path of all entries under then specified path through the deque.n n Args:n root(Any): Root registry.n key_path(str): The relative specific path under the root registry.n n Returns:n A list of all entries under the keys.n """n all_keys_list: list = list()n n qeque = deque()n qeque.append(key_path)n n while len(qeque) != 0:n sub_key_path = qeque.popleft()n n for item in get_sub_keys(root, sub_key_path):n item_path = os.path.join(sub_key_path, item)n n if len(get_sub_keys(root, item_path)) != 0:n qeque.append(item_path)n all_keys_list.append(item_path)n else:n all_keys_list.append(item_path)n n return all_keys_listn n ndef main():n """The entry function to be executed.n n Returns:n Nonen """n clsid_all_keys_list = get_all_keys(HKEY_CURRENT_USER, CLSID_PATH)n premium_all_keys_list = get_all_keys(HKEY_CURRENT_USER, PREMIUM_PATH)n premium_sub_keys_list = [os.path.join(PREMIUM_PATH, item) for item in get_sub_keys(HKEY_CURRENT_USER, PREMIUM_PATH)]n print(f"premium_sub_keys_list: {premium_sub_keys_list}")n n for clsid_item in clsid_all_keys_list:n if "Info" in clsid_item:n clsid_item_prefix = os.path.dirname(clsid_item)n print(f"# Info item: {clsid_item}")n winreg.DeleteKeyEx(HKEY_CURRENT_USER, clsid_item)n winreg.DeleteKeyEx(HKEY_CURRENT_USER, clsid_item_prefix)n n # The outermost folder is not deleted.n for premium_item in reversed(premium_all_keys_list):n if "Servers" in premium_item:n print(f"Tips: Servers => {premium_item} will not be deleted.")n passn elif premium_item in premium_sub_keys_list:n print(f"Tips: Servers => {premium_item} will not be deleted.")n passn else:n winreg.DeleteKeyEx(HKEY_CURRENT_USER, premium_item)n n nif __name__ == "__main__":n print("Start to delete registry...")n main()n print("Task done.", "Windows will closed after 5 seconds...", sep="n")n n for i in range(5):n time.sleep(1)n print("*" * (i + 1))
打包为exe,可以发送给没有python环境的人
pyinstaller -F xxx.py
上一篇:nagito
下一篇:navicat 绿化版