Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit 7115125

Browse files
committed
(Suggest to) uninstall previous versions
1 parent 1cb944d commit 7115125

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

ElixirWeb.iss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ Filename: "{tmp}\ISCC.exe"; Parameters: "/dSkipWelcome /dNoCompression Elixir.is
9090
Filename: "{tmp}\Output\elixir-v{#StrInspectScriptConst('CacheSelectedRelease.Version')}-setup.exe"; Flags: nowait; StatusMsg: "Starting Elixir installer..."
9191

9292
[Tasks]
93+
Name: "unins_previous"; Description: "Uninstall previous version at {#StrInspectScriptConst('GetPreviousAppPath')} (Recommended)"; Check: CheckPreviousVersionExists
9394
Name: "erlang"; Description: "Install Erlang"; Check: CheckToInstallErlang
9495
Name: "erlang\32"; Description: "{#StrInspectScriptConst('GlobalErlangData.Name32')}"; Flags: exclusive
9596
Name: "erlang\64"; Description: "{#StrInspectScriptConst('GlobalErlangData.Name64')}"; Flags: exclusive; Check: IsWin64
@@ -103,6 +104,7 @@ Name: "existingpath"; Description: "Append {#StrInspectScriptConst('GetLatestErl
103104
#include "src\elixir_lookup.iss"
104105
#include "src\erlang_data.iss"
105106
#include "src\erlang_env.iss"
107+
#include "src\unins_previous.iss"
106108
107109
var
108110
GlobalPageSelRelease: TInputOptionWizardPage;
@@ -129,10 +131,14 @@ end;
129131
procedure CurPageChanged(CurPageID: Integer);
130132
var
131133
ListBoxesToCheck: array[0..1] of TNewCheckListBox;
134+
_int: Integer;
132135
begin
133136
if CurPageID = wpPreparing then begin
134137
// We're on the page after the "Ready To Install" page but before [Files] and [Run] are processed
135138
139+
if IsTaskSelected('unins_previous') then
140+
ExecAsOriginalUser(GetPreviousUninsExe, '/SILENT', '', SW_SHOW, ewWaitUntilTerminated, _int);
141+
136142
with GlobalErlangData do begin
137143
if IsTaskSelected('erlang\32') then
138144
// 32-bit OTP needs to be downloaded before it's installed

src/unins_previous.iss

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// unins_previous.iss - Functionality to check for previous Elixir installations
2+
// Copyright 2014 Chris Hyndman
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
[Code]
17+
18+
function GetPreviousUninsExe: String;
19+
var
20+
UninsPath: String;
21+
begin
22+
UninsPath := '';
23+
Result := '';
24+
if RegQueryStringValue(HKLM, 'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Elixir_is1', 'UninstallString', UninsPath) then begin
25+
Result := RemoveQuotes(UninsPath);
26+
end else if RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Elixir_is1', 'UninstallString', UninsPath) then begin
27+
Result := RemoveQuotes(UninsPath);
28+
end else if RegQueryStringValue(HKCU, 'Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Elixir_is1', 'UninstallString', UninsPath) then begin
29+
Result := RemoveQuotes(UninsPath);
30+
end else if RegQueryStringValue(HKCU, 'Software\Microsoft\Windows\CurrentVersion\Uninstall\Elixir_is1', 'UninstallString', UninsPath) then begin
31+
Result := RemoveQuotes(UninsPath);
32+
end;
33+
end;
34+
35+
function GetPreviousAppPath: String;
36+
begin
37+
Result := RemoveBackslashUnlessRoot(ExtractFilePath(GetPreviousUninsExe));
38+
end;
39+
40+
function CheckPreviousVersionExists: Boolean;
41+
begin
42+
Result := (GetPreviousUninsExe <> '');
43+
end;

0 commit comments

Comments
 (0)