diff --git a/__pycache__/client_agent_v2.cpython-314.pyc b/__pycache__/client_agent_v2.cpython-314.pyc index 30bb051..e9ebff3 100644 Binary files a/__pycache__/client_agent_v2.cpython-314.pyc and b/__pycache__/client_agent_v2.cpython-314.pyc differ diff --git a/client_agent_v2.py b/client_agent_v2.py index 055694a..ea530ed 100644 --- a/client_agent_v2.py +++ b/client_agent_v2.py @@ -19,9 +19,11 @@ from tkinter import messagebox, ttk APP_NAME = "InvWebClientAgentV2" -CLIENT_DISPLAY_NAME = "Inv_web Client" +CLIENT_DISPLAY_NAME = "Inventera Client" +WINDOWS_CONFIG_DIR_NAME = CLIENT_DISPLAY_NAME +LEGACY_WINDOWS_CONFIG_DIR_NAMES = (APP_NAME,) AUTOSTART_VALUE_NAME = CLIENT_DISPLAY_NAME -LEGACY_AUTOSTART_VALUE_NAMES = ("InvWebClientAgentV2",) +LEGACY_AUTOSTART_VALUE_NAMES = ("Inv_web Client", "InvWebClientAgentV2") AUTOSTART_REGISTRY_PATH = r"Software\Microsoft\Windows\CurrentVersion\Run" DEFAULT_SERVER = "http://127.0.0.1:5050" DEFAULT_TOKEN = "change-me-client-token" @@ -73,7 +75,7 @@ def is_macos(): def config_dir(): if is_windows(): base = os.environ.get("APPDATA") or str(Path.home()) - return Path(base) / APP_NAME + return Path(base) / WINDOWS_CONFIG_DIR_NAME return Path.home() / f".{APP_NAME.lower()}" @@ -81,6 +83,13 @@ def config_path(): return config_dir() / "config.json" +def legacy_windows_config_paths(): + if not is_windows(): + return [] + base = Path(os.environ.get("APPDATA") or str(Path.home())) + return [base / directory_name / "config.json" for directory_name in LEGACY_WINDOWS_CONFIG_DIR_NAMES] + + def resource_path(relative_path): base_dir = Path(getattr(sys, "_MEIPASS", Path(__file__).resolve().parent)) return base_dir / relative_path @@ -144,14 +153,46 @@ def disable_windows_autostart(): pass +def remove_legacy_windows_autostart(): + if not is_windows(): + return + import winreg + + try: + with winreg.OpenKey( + winreg.HKEY_CURRENT_USER, + AUTOSTART_REGISTRY_PATH, + 0, + winreg.KEY_SET_VALUE, + ) as key: + for value_name in LEGACY_AUTOSTART_VALUE_NAMES: + try: + winreg.DeleteValue(key, value_name) + except FileNotFoundError: + pass + except FileNotFoundError: + pass + + def load_config(): path = config_path() - if not path.exists(): - return {} - try: - return json.loads(path.read_text(encoding="utf-8")) - except Exception: - return {} + candidates = [path, *legacy_windows_config_paths()] + for candidate in candidates: + if not candidate.exists(): + continue + try: + config = json.loads(candidate.read_text(encoding="utf-8")) + except Exception: + continue + if not isinstance(config, dict): + continue + if candidate != path: + try: + save_config(config) + except OSError: + pass + return config + return {} def save_config(config): @@ -2079,6 +2120,7 @@ def save_connection_config(args): config["server"] = normalize_server_url(args.server) config["token"] = (args.token or DEFAULT_TOKEN).strip() save_config(config) + remove_legacy_windows_autostart() def main(): diff --git a/client_agent_v2_installer.iss b/client_agent_v2_installer.iss index 837a4a0..032c28a 100644 --- a/client_agent_v2_installer.iss +++ b/client_agent_v2_installer.iss @@ -1,6 +1,6 @@ -#define MyAppName "Inv_web Client" +#define MyAppName "Inventera Client" #define MyAppVersion "2.0" -#define MyAppPublisher "Inv_web" +#define MyAppPublisher "Inventera" #define MyAppExeName "Inv_web Client.exe" #define RustDeskInstaller "installer\prerequisites\rustdesk.exe" @@ -9,9 +9,11 @@ AppId={{6F0D1694-CACE-4F7D-97A2-BB01C240775B} AppName={#MyAppName} AppVersion={#MyAppVersion} AppPublisher={#MyAppPublisher} -DefaultDirName={localappdata}\Programs\{#MyAppName} +DefaultDirName={autopf}\{#MyAppName} DefaultGroupName={#MyAppName} PrivilegesRequired=admin +UsePreviousAppDir=no +UsePreviousGroup=no OutputDir=dist OutputBaseFilename=Inv_web_Client_Setup SetupIconFile=picture\ICON\icon_client.ico @@ -35,13 +37,23 @@ Source: "dist\Inv_web Client\*"; DestDir: "{app}"; Flags: ignoreversion recurses Source: "{#RustDeskInstaller}"; DestDir: "{tmp}"; DestName: "rustdesk-installer.exe"; Flags: deleteafterinstall noencryption; Check: ShouldInstallRustDesk Source: "installer\configure_rustdesk.ps1"; DestDir: "{tmp}"; Flags: deleteafterinstall noencryption; Check: ShouldInstallRustDesk +[InstallDelete] +; Remove shortcuts from releases whose target was inside the elevated +; administrator's LocalAppData. CloseApplications asks Restart Manager to +; close a legacy client before this known application folder is removed. +Type: files; Name: "{commondesktop}\Inv_web Client.lnk" +Type: filesandordirs; Name: "{commonprograms}\Inv_web Client" +Type: filesandordirs; Name: "{localappdata}\Programs\Inv_web Client" + [Icons] Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" [Run] -Filename: "{app}\{#MyAppExeName}"; Parameters: "--configure-only --server ""{code:GetServerAddress}"""; Flags: runhidden waituntilterminated -Filename: "{app}\{#MyAppExeName}"; Description: "Запустить {#MyAppName}"; Flags: nowait postinstall skipifsilent unchecked +; The client configuration belongs to the interactive user who started Setup, +; not to the administrator whose credentials were entered in the UAC dialog. +Filename: "{app}\{#MyAppExeName}"; Parameters: "--configure-only --server ""{code:GetServerAddress}"""; Flags: runhidden waituntilterminated runasoriginaluser +Filename: "{app}\{#MyAppExeName}"; Description: "Запустить {#MyAppName}"; Flags: nowait postinstall skipifsilent runasoriginaluser [Code] var @@ -66,7 +78,7 @@ begin wpWelcome, 'Режим установки', 'Выберите состав установки', - 'Клиент Inv_web устанавливается во всех режимах.', + 'Клиент Inventera устанавливается во всех режимах.', True, False ); @@ -246,7 +258,7 @@ begin ConfigurationPath := ExpandConstant('{tmp}\rustdesk-options.ini'); ErrorPath := ExpandConstant('{tmp}\rustdesk-error.txt'); LogPath := ExpandConstant( - '{commonappdata}\Inv_web Client\rustdesk-install.log' + '{commonappdata}\Inventera Client\rustdesk-install.log' ); DeleteFile(ErrorPath); ConfigurationText := diff --git a/installer/configure_rustdesk.ps1 b/installer/configure_rustdesk.ps1 index ed85b73..8523902 100644 --- a/installer/configure_rustdesk.ps1 +++ b/installer/configure_rustdesk.ps1 @@ -11,7 +11,7 @@ $ErrorActionPreference = 'Stop' -$logDirectory = Join-Path $env:ProgramData 'Inv_web Client' +$logDirectory = Join-Path $env:ProgramData 'Inventera Client' $LogPath = Join-Path $logDirectory 'rustdesk-install.log' function Write-InstallLog {