import winreg
def remove_outlook_account():
try:
root = winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER)
key_path = r"Software\Microsoft\Office\Outlook"
key = winreg.OpenKey(root, key_path, 0, winreg.KEY_ALL_ACCESS)
# Modify the registry value to remove the Outlook account
winreg.SetValueEx(key, "LastLoggedOnUser", 0, winreg.REG_SZ, "")
# Close the registry key
winreg.CloseKey(key)
print("Outlook account successfully removed.")
except Exception as e:
print("Error occurred while removing Outlook account:", e)
# Call the function to remove the Outlook account
remove_outlook_account()