Installer: "Auto-run for all users" with Service checked only on initial setup

This commit is contained in:
Nodir Temirkhodjaev 2024-07-03 12:52:04 +05:00
parent 2fbbe2c38f
commit efd02e838d
3 changed files with 28 additions and 9 deletions

View File

@ -96,6 +96,7 @@ Filename: "{app}\driver\scripts\reinstall.bat"; Parameters: {code:DriverInstallA
Filename: "{#APP_EXE}"; Parameters: "-i portable"; Tasks: portable Filename: "{#APP_EXE}"; Parameters: "-i portable"; Tasks: portable
Filename: "{#APP_EXE}"; Parameters: "-i service"; Tasks: service Filename: "{#APP_EXE}"; Parameters: "-i service"; Tasks: service
Filename: "{#APP_EXE}"; Parameters: "-i auto-run"; Tasks: service; Check: (not IsUpgrade)
Filename: "{#APP_EXE}"; Parameters: "-i explorer"; Flags: runasoriginaluser; Tasks: explorer Filename: "{#APP_EXE}"; Parameters: "-i explorer"; Flags: runasoriginaluser; Tasks: explorer
Filename: "sc.exe"; Parameters: "start {#APP_SVC_NAME}"; Description: "Start service"; \ Filename: "sc.exe"; Parameters: "start {#APP_SVC_NAME}"; Description: "Start service"; \
@ -133,6 +134,8 @@ Root: HKLM; Subkey: "SOFTWARE\{#APP_NAME}"; Flags: dontcreatekey uninsdeletekeyi
Root: HKLM; Subkey: "SOFTWARE\{#APP_NAME}"; ValueName: "passwordHash"; Flags: dontcreatekey uninsdeletevalue Root: HKLM; Subkey: "SOFTWARE\{#APP_NAME}"; ValueName: "passwordHash"; Flags: dontcreatekey uninsdeletevalue
[Code] [Code]
var
IsUpgradeVar: boolean;
function ParamExists(const Value: string): Boolean; function ParamExists(const Value: string): Boolean;
var var
@ -180,13 +183,19 @@ var
UninstallKey: String; UninstallKey: String;
begin begin
UninstallKey := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppName")}_is1'); UninstallKey := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppName")}_is1');
if not RegQueryStringValue(HKLM, UninstallKey, 'UninstallString', Result) then if not RegQueryStringValue(HKLM, UninstallKey, 'UninstallString', Result) then
RegQueryStringValue(HKCU, UninstallKey, 'UninstallString', Result); RegQueryStringValue(HKCU, UninstallKey, 'UninstallString', Result);
end; end;
procedure SetupIsUpgrade();
begin
IsUpgradeVar := GetUninstallString() <> '';
end;
function IsUpgrade(): Boolean; function IsUpgrade(): Boolean;
begin begin
Result := GetUninstallString() <> ''; Result := IsUpgradeVar;
end; end;
function VCRedist86Exists(): Boolean; function VCRedist86Exists(): Boolean;
@ -397,6 +406,8 @@ begin
Exit; Exit;
end; end;
SetupIsUpgrade();
if IsUpgrade() then if IsUpgrade() then
begin begin
Result := True; Result := True;

View File

@ -257,15 +257,17 @@ void FortManager::install(const char *arg)
return; return;
switch (arg[0]) { switch (arg[0]) {
case 'b': { // "boot_filter" case 'b': { // "boot-filter"
DriverCommon::provRegister(/*bootFilter=*/true); // Register booted provider DriverCommon::provRegister(/*bootFilter=*/true); // Register booted provider
} break; } break;
case 'p': { // "portable" case 'p': { // "portable"
FortManager::setupPortableResource(); FortManager::setupPortableResource();
StartupUtil::setPortable(true); StartupUtil::setPortable(true);
} break; } break;
case 's': { // "service" case 'a': { // "auto-run"
StartupUtil::setAutoRunMode(StartupUtil::StartupAllUsers); StartupUtil::setAutoRunMode(StartupUtil::StartupAllUsers);
} break;
case 's': { // "service"
StartupUtil::setServiceInstalled(true); StartupUtil::setServiceInstalled(true);
OsUtil::endRestartClients(); OsUtil::endRestartClients();
@ -278,16 +280,17 @@ void FortManager::install(const char *arg)
void FortManager::uninstall(const char *arg) void FortManager::uninstall(const char *arg)
{ {
StartupUtil::setAutoRunMode(StartupUtil::StartupDisabled); // Remove auto-run // COMPAT: Remove Global Windows Explorer integration
StartupUtil::clearGlobalExplorerIntegrated();
StartupUtil::setExplorerIntegrated(false); // Remove Windows Explorer integration StartupUtil::setExplorerIntegrated(false); // Remove Windows Explorer integration
StartupUtil::stopService(ServiceControlStopUninstall); // Quit clients & Stop service StartupUtil::stopService(ServiceControlStopUninstall); // Quit clients & Stop service
StartupUtil::setServiceInstalled(false); // Uninstall service StartupUtil::setServiceInstalled(false); // Uninstall service
StartupUtil::clearGlobalExplorerIntegrated(); // COMPAT: Remove Global Windows Explorer
// integration
if (!arg) { if (!arg) {
StartupUtil::setAutoRunMode(StartupUtil::StartupDisabled); // Remove auto-run
DriverCommon::provUnregister(); // Unregister booted provider DriverCommon::provUnregister(); // Unregister booted provider
} }
} }

View File

@ -203,8 +203,13 @@ void StartupUtil::setAutoRunMode(int mode, const QString &defaultLanguage)
if (mode == StartupDisabled) if (mode == StartupDisabled)
return; return;
const QString command = wrappedAppFilePath() QStringList commandList = { wrappedAppFilePath(), "--launch" };
+ (defaultLanguage.isEmpty() ? QString() : " --lang " + defaultLanguage);
if (!defaultLanguage.isEmpty()) {
commandList << "--lang" << defaultLanguage;
}
const QString command = commandList.join(' ');
switch (mode) { switch (mode) {
case StartupCurrentUser: case StartupCurrentUser: