Initial SyncVito release with installer updater
This commit is contained in:
commit
b9e4c09f49
41 files changed
+4331
No files matched your search
@@ -0,0 +1,31 @@
|
||||
"""Verwaltung des benutzerspezifischen Windows-Autostarts."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
from contextlib import suppress
|
||||
from pathlib import Path
|
||||
|
||||
__all__ = ["set_autostart"]
|
||||
|
||||
|
||||
def set_autostart(enabled: bool) -> None:
|
||||
"""Setzt oder entfernt SyncVito unter HKCU\\...\\Run."""
|
||||
if os.name != "nt":
|
||||
return
|
||||
import winreg
|
||||
|
||||
key_path = r"Software\Microsoft\Windows\CurrentVersion\Run"
|
||||
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, key_path, 0, winreg.KEY_SET_VALUE) as key:
|
||||
if enabled:
|
||||
executable = Path(sys.executable)
|
||||
if getattr(sys, "frozen", False):
|
||||
command = f'"{executable}" --minimized'
|
||||
else:
|
||||
entry = Path(__file__).resolve().parents[2] / "main.py"
|
||||
command = f'"{executable}" "{entry}" --minimized'
|
||||
winreg.SetValueEx(key, "SyncVito", 0, winreg.REG_SZ, command)
|
||||
else:
|
||||
with suppress(FileNotFoundError):
|
||||
winreg.DeleteValue(key, "SyncVito")
|
||||
Reference in new issue
Block a user