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 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: "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
[Code]
var
IsUpgradeVar: boolean;
function ParamExists(const Value: string): Boolean;
var
@ -180,13 +183,19 @@ var
UninstallKey: String;
begin
UninstallKey := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppName")}_is1');
if not RegQueryStringValue(HKLM, UninstallKey, 'UninstallString', Result) then
RegQueryStringValue(HKCU, UninstallKey, 'UninstallString', Result);
end;
procedure SetupIsUpgrade();
begin
IsUpgradeVar := GetUninstallString() <> '';
end;
function IsUpgrade(): Boolean;
begin
Result := GetUninstallString() <> '';
Result := IsUpgradeVar;
end;
function VCRedist86Exists(): Boolean;
@ -397,6 +406,8 @@ begin
Exit;
end;
SetupIsUpgrade();
if IsUpgrade() then
begin
Result := True;

View File

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

View File

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