def unregister(target, current=True, verbose=True):
    """Unregister a Python distribution from Windows registry and remove Start Menu shortcuts"""
    root = winreg.HKEY_CURRENT_USER if current else winreg.HKEY_LOCAL_MACHINE
    has_pywin32 = _has_pywin32()

    if verbose:
         print(f'Removing WinPython registry entries for {target}')
   
    permanent_entries, dynamic_entries,  core_entries , lost_entries = register_in_registery(target)

    # List of keys to attempt to delete, ordered from most specific to general
    keys_to_delete = sorted(list(set(key_path for   key_path , name, value  in  (dynamic_entries +  core_entries + lost_entries))), key=len, reverse=True)

    rootkey_name = "HKEY_CURRENT_USER" if root == winreg.HKEY_CURRENT_USER else "HKEY_LOCAL_MACHINE"
    for key_path in keys_to_delete:
         _delete_reg_key(root, key_path, verbose=verbose)

    # Remove start menu shortcuts
    if has_pywin32:
        if verbose:
            print(f'Removing WinPython menu for all icons in {target.parent}')
        _remove_start_menu_folder(target, current=current, has_pywin32=True)
        # The original code had commented out code to delete .lnk files individually.
    else:
        print("Skipping start menu removal as pywin32 package is needed.")
Unregister a Python distribution from Windows registry and remove Start Menu shortcuts
winpython/associate.py