From f2bf9539390d97f50cae183b92f9a2bf5be7ffeb Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Wed, 27 Jun 2018 15:01:19 +0100 Subject: [PATCH] detect system installation on user installation fixes #52965 --- build/gulpfile.vscode.win32.js | 3 ++- build/win32/code.iss | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/build/gulpfile.vscode.win32.js b/build/gulpfile.vscode.win32.js index a9cd1a11b7a..5a03f23ba7d 100644 --- a/build/gulpfile.vscode.win32.js +++ b/build/gulpfile.vscode.win32.js @@ -81,7 +81,8 @@ function buildWin32Setup(arch, target) { AppMutex: product.win32MutexName, Arch: arch, AppId: arch === 'ia32' ? ia32AppId : x64AppId, - IncompatibleAppId: arch === 'ia32' ? x64AppId : ia32AppId, + IncompatibleTargetAppId: arch === 'ia32' ? product.win32AppId : product.win32x64AppId, + IncompatibleArchAppId: arch === 'ia32' ? x64AppId : ia32AppId, AppUserId: product.win32AppUserModelId, ArchitecturesAllowed: arch === 'ia32' ? '' : 'x64', ArchitecturesInstallIn64BitMode: arch === 'ia32' ? '' : 'x64', diff --git a/build/win32/code.iss b/build/win32/code.iss index 3126cb76789..552d79f2439 100644 --- a/build/win32/code.iss +++ b/build/win32/code.iss @@ -957,14 +957,26 @@ Root: {#EnvironmentRootKey}; Subkey: "{#EnvironmentKey}"; ValueType: expandsz; V // Don't allow installing conflicting architectures function InitializeSetup(): Boolean; var + RegRootKey: String; RegKey: String; ThisArch: String; AltArch: String; begin Result := True; - if IsWin64 then begin - RegKey := 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + copy('{#IncompatibleAppId}', 2, 38) + '_is1'; +#if "user" == InstallTarget + if '{#Arch}' = 'ia32' then RegRootKey := 'HKLM32' else RegRootKey := 'HKLM64'; + RegKey := 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + copy('{#IncompatibleTargetAppId}', 2, 38) + '_is1'; + + if RegKeyExists(RegRootKey, RegKey) then begin + if MsgBox('{#NameShort} is already installed on this system for all users. Are you sure you want to install it for this user?', mbConfirmation, MB_YESNO) = IDNO then begin + Result := false; + end; + end; +#endif + + if Result and IsWin64 then begin + RegKey := 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + copy('{#IncompatibleArchAppId}', 2, 38) + '_is1'; if '{#Arch}' = 'ia32' then begin Result := not RegKeyExists({#Uninstall64RootKey}, RegKey);