Skip to content

Commit 282e785

Browse files
committed
installer changes
1 parent 5576c5b commit 282e785

File tree

7 files changed

+442
-10
lines changed

7 files changed

+442
-10
lines changed

admin/win/msi/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ install(FILES
3232
Nextcloud.wxs
3333
${CMAKE_CURRENT_BINARY_DIR}/RegistryCleanup.vbs
3434
RegistryCleanupCustomAction.wxs
35+
UinstallOldClientDlg.wxs
36+
License.rtf
3537
gui/banner.bmp
3638
gui/dialog.bmp
3739
DESTINATION msi/)

admin/win/msi/License.rtf

Lines changed: 272 additions & 0 deletions
Large diffs are not rendered by default.

admin/win/msi/Nextcloud.wxs

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
<RegistrySearch Id="RegistryInstallDir" Type="raw" Root="HKLM" Key="Software\$(var.AppVendor)\$(var.AppName)" Win64="no" />
4646
</Property>
4747

48+
<Property Id="OLDCLIENTDIR">C:\Windows\System32\</Property>
49+
4850
<!-- Detect legacy NSIS installation -->
4951
<Property Id="NSIS_UNINSTALLEXE">
5052
<RegistrySearch Id="RegistryLegacyUninstallString" Type="file" Root="HKLM" Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\$(var.AppName)" Name="UninstallString" Win64="no">
@@ -62,6 +64,49 @@
6264
<SetProperty Id="ExecNsisUninstaller" Value="&quot;$(var.AppShortName)&quot; &quot;[NSIS_UNINSTALLEXE]&quot;" Before="ExecNsisUninstaller" Sequence="execute" />
6365
<SetProperty Id="RemoveNavigationPaneEntries" Value="&quot;$(var.AppName)&quot;" Before="RemoveNavigationPaneEntries" Sequence="execute" />
6466

67+
<CustomAction Id="UninstallOldClient"
68+
Script="vbscript"
69+
Execute="immediate">
70+
<![CDATA[
71+
const HKEY_CLASSES_ROOT = &H80000000
72+
const HKEY_CURRENT_USER = &H80000001
73+
const HKEY_LOCAL_MACHINE = &H80000002
74+
const HKEY_USERS = &H80000003
75+
const HKEY_CURRENT_CONFIG = &H80000004
76+
const HKEY_DYN_DATA = &H80000005
77+
strComputer = "."
78+
oldClientExists = False
79+
userName = CreateObject("WScript.Network").UserName
80+
configPath = "C:\Users\"& userName &"\AppData\Roaming\MagentaCLOUD"
81+
configFile = configPath & "\magentacloud.cfg"
82+
jsonPath = "C:\Users\"& userName &"\AppData\Local\MagentaCLOUD"
83+
jsonFile = jsonFile & "\magentacloud.cfg"
84+
set oWsh = createobject("wscript.shell")
85+
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
86+
& strComputer & "\root\default:StdRegProv")
87+
strKeyPath = "software\WOW6432Node\microsoft\windows\currentversion\uninstall" ' Root level
88+
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
89+
For Each subkey In arrSubKeys
90+
on error resume next
91+
sDisplayName = oWsh.Regread("HKLM\" & strKeyPath & "\" & subkey & "\DisplayName")
92+
if err.number = 0 then
93+
on error goto 0
94+
if sDisplayName = "MagentaCLOUD Software" then
95+
oldClientExists = True
96+
sUninstall = oWsh.Regread("HKLM\" & strKeyPath & "\" & subkey & "\UnInstallString")
97+
End If
98+
End If
99+
Next
100+
on error goto 0
101+
if oldClientExists Then
102+
sUninstall = sUnInstall & " /qn"
103+
command = "/k " & sUninstall
104+
Set objShell = CreateObject("Shell.Application")
105+
objShell.ShellExecute "cmd.exe", command, "", "runas", 0
106+
End If
107+
]]>
108+
</CustomAction>
109+
65110
<!-- Ensure ACLs -->
66111
<Binary Id="EnsureACL" SourceFile="EnsureACL.js" />
67112
<SetProperty Id="EnsureACL" Before="EnsureACL" Value="[INSTALLDIR]" Sequence="execute" />
@@ -110,18 +155,20 @@
110155
-->
111156

112157
<!-- Custom license -->
113-
<!--
114158
<WixVariable Id="WixUILicenseRtf" Value="$(var.AppLicenseRtf)" />
115-
-->
116159

117160
<UI>
118161
<UIRef Id="WixUI_FeatureTree" />
119162
<UIRef Id="WixUI_ErrorProgressText" />
120163

121-
<!-- Skip the license page -->
122-
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="CustomizeDlg" Order="3">1</Publish>
123-
<!-- Skip the page on the way back too -->
124-
<Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="3">1</Publish>
164+
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="LicenseAgreementDlg" Order="3">1</Publish>
165+
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="CustomizeDlg" Order="3">1</Publish>
166+
<Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg" Order="3">1</Publish>
167+
168+
<UIRef Id="MigrationDialogUI"/>
169+
170+
<Publish Dialog="MigrationDialog" Control="Weiter" Event="DoAction" Value="UninstallOldClient">Not Installed</Publish>
171+
<Publish Dialog="MigrationDialog" Control="Weiter" Event="EndDialog" Value="Return">1</Publish>
125172

126173
<!-- https://wixtoolset.org/documentation/manual/v3/howtos/ui_and_localization/run_program_after_install.html -->
127174
<Publish Dialog="ExitDialog"
@@ -137,15 +184,18 @@
137184
<!-- "Launch" checkbox -->
138185
<Property Id="WixShellExecTarget" Value="[#MainExecutable]" />
139186
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
140-
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch $(var.AppName)" />
187+
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="$(var.AppName) starten" />
141188
<SetProperty Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1" Before="CostInitialize">NOT (LAUNCH=0)</SetProperty>
142189

143190
<!-- Components -->
144191
<Directory Id="TARGETDIR" Name="SourceDir">
145192
<Directory Id="$(var.PlatformProgramFilesFolder)" Name="PFiles">
146193
<Directory Id="INSTALLDIR" Name="$(var.AppName)">
147194
<!-- Shell Extensions -->
148-
<Directory Id="ShellExtDir" />
195+
<Directory Id="OLDCLIENTDIR" Name="UninstallString">
196+
<!-- Shell Extensions -->
197+
<Directory Id="ShellExtDir" Name="shellext" />
198+
</Directory>
149199
</Directory>
150200
</Directory>
151201

admin/win/msi/OEM.wxi.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
<?define AppIcon = "@APPLICATION_ICON_NAME@.ico" ?>
1616
<?define AppExe = "@APPLICATION_EXECUTABLE@.exe" ?>
17+
<?define OldAppName = "MagentaCLOUD Software" ?>
1718

1819
<?define AppHelpLink = "https://@APPLICATION_DOMAIN@/" ?>
1920
<?define AppInfoLink = "$(var.AppHelpLink)" ?>
@@ -24,6 +25,7 @@
2425
and uncomment <WixVariable Id="WixUILicenseRtf"...
2526
<?define AppLicenseRtf = "path\License.rtf" ?>
2627
-->
28+
<?define AppLicenseRtf = "$(sys.CURRENTDIR)\License.rtf" ?>
2729

2830
<!-- App Version -->
2931
<?define VerMajor = "@MIRALL_VERSION_MAJOR@" ?>

admin/win/msi/RegisterCleanup.vbs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
On Error goto 0
2+
3+
Const HKEY_LOCAL_MACHINE = &H80000002
4+
5+
Const strObjRegistry = "winmgmts:\\.\root\default:StdRegProv"
6+
7+
Function RegistryDeleteKeyRecursive(regRoot, strKeyPath)
8+
Set objRegistry = GetObject(strObjRegistry)
9+
objRegistry.EnumKey regRoot, strKeyPath, arrSubkeys
10+
If IsArray(arrSubkeys) Then
11+
For Each strSubkey In arrSubkeys
12+
RegistryDeleteKeyRecursive regRoot, strKeyPath & "\" & strSubkey
13+
Next
14+
End If
15+
objRegistry.DeleteKey regRoot, strKeyPath
16+
End Function
17+
18+
Function RegistryListSubkeys(regRoot, strKeyPath)
19+
Set objRegistry = GetObject(strObjRegistry)
20+
objRegistry.EnumKey regRoot, strKeyPath, arrSubkeys
21+
RegistryListSubkeys = arrSubkeys
22+
End Function
23+
24+
Function GetUserSID()
25+
Dim objWshNetwork, objUserAccount
26+
27+
Set objWshNetwork = CreateObject("WScript.Network")
28+
29+
Set objUserAccount = GetObject("winmgmts://" & objWshNetwork.UserDomain & "/root/cimv2").Get("Win32_UserAccount.Domain='" & objWshNetwork.ComputerName & "',Name='" & objWshNetwork.UserName & "'")
30+
GetUserSID = objUserAccount.SID
31+
End Function
32+
33+
Function RegistryCleanupSyncRootManager()
34+
strSyncRootManagerKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SyncRootManager"
35+
36+
arrSubKeys = RegistryListSubkeys(HKEY_LOCAL_MACHINE, strSyncRootManagerKeyPath)
37+
38+
If IsArray(arrSubkeys) Then
39+
arrSubkeys=Filter(arrSubkeys, Session.Property("APPNAME"))
40+
End If
41+
If IsArray(arrSubkeys) Then
42+
arrSubkeys=Filter(arrSubkeys, GetUserSID())
43+
End If
44+
45+
If IsArray(arrSubkeys) Then
46+
For Each strSubkey In arrSubkeys
47+
RegistryDeleteKeyRecursive HKEY_LOCAL_MACHINE, strSyncRootManagerKeyPath & "\" & strSubkey
48+
Next
49+
End If
50+
End Function
51+
52+
Function RegistryCleanup()
53+
RegistryCleanupSyncRootManager()
54+
End Function
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
*
4+
* Copyright (C) by Michael Schuster <michael@schuster.ms>
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful, but
12+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* for more details.
15+
*
16+
-->
17+
<?include $(sys.CURRENTDIR)OEM.wxi?>
18+
<?include $(sys.CURRENTDIR)Platform.wxi?>
19+
20+
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
21+
22+
<!--
23+
When to change the Product GUID:
24+
https://www.firegiant.com/wix/tutorial/upgrades-and-modularization/
25+
https://www.firegiant.com/wix/tutorial/upgrades-and-modularization/checking-for-oldies/
26+
27+
We change the Product Id for every release, to let up-/downgrading always work.
28+
But we then should never change the UpgradeCode.
29+
-->
30+
<Fragment>
31+
<UI Id="MigrationDialogUI">
32+
33+
<DialogRef Id="ExitDialog"/>
34+
35+
<Dialog Id="MigrationDialog" Width="370" Height="270" Title="$(var.AppName) $(var.PlatformBitness)">
36+
37+
<Control Id="Weiter" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Cancel="yes" Text="Weiter" >
38+
<!-- <Publish Event="DoAction" Value="RemoveOldClient">updateCheckboxResult = 1 and aquisitionCheckboxResult = 1 and Not Installed</Publish>
39+
<Publish Event="OnExit" Value="success"></Publish> -->
40+
</Control>
41+
<Control Id="Bitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="234" TabSkip="no" Text="!(loc.ExitDialogBitmap)" />
42+
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Disabled="yes" Text="Back" />
43+
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
44+
<Control Id="Description" Type="Text" X="135" Y="70" Width="220" Height="40" Transparent="yes" NoPrefix="yes" Text="MagentaCLOUD durchsucht ihren PC nach früheren Versionen. Sollte eine frühere Version vorhanden sein, so wird sie deinstalliert werden, da sie nicht länger kompatibel ist." />
45+
<Control Id="Title" Type="Text" X="135" Y="20" Width="220" Height="60" Transparent="yes" NoPrefix="yes" Text="!(loc.ExitDialogTitle)" />
46+
</Dialog>
47+
<InstallUISequence>
48+
<Show Dialog="MigrationDialog" After="ExecuteAction" />
49+
</InstallUISequence>
50+
</UI>
51+
</Fragment>
52+
</Wix>

admin/win/msi/make-msi.bat.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ exit 0
107107
set codepage=%~1
108108

109109
echo :: Compiling MSI project for codepage !codepage!
110-
"%WIX%\bin\candle.exe" -dcodepage=!codepage! -dProductCode=%PRODUCTCODE% -dPlatform=%BuildArch% -arch %BuildArch% -dHarvestAppDir="%HarvestAppDir%" -ext WixUtilExtension NCMsiHelper.wxs WinShellExt.wxs collect.wxs Nextcloud.wxs RegistryCleanupCustomAction.wxs
110+
"%WIX%\bin\candle.exe" -dcodepage=!codepage! -dProductCode=%PRODUCTCODE% -dPlatform=%BuildArch% -arch %BuildArch% -dHarvestAppDir="%HarvestAppDir%" -ext WixUtilExtension NCMsiHelper.wxs WinShellExt.wxs collect.wxs Nextcloud.wxs RegistryCleanupCustomAction.wxs UinstallOldClientDlg.wxs
111111
if %ERRORLEVEL% neq 0 exit %ERRORLEVEL%
112112
echo/
113113

@@ -121,7 +121,7 @@ exit 0
121121
set culture=%%c
122122

123123
echo :: Linking MSI project for !culture!
124-
"%WIX%\bin\light.exe" -sw1076 -ext WixUIExtension -ext WixUtilExtension -cultures:!culture!;en-us NCMsiHelper.wixobj WinShellExt.wixobj collect.wixobj Nextcloud.wixobj RegistryCleanupCustomAction.wixobj -out "!culture!_@MSI_INSTALLER_FILENAME@"
124+
"%WIX%\bin\light.exe" -sw1076 -ext WixUIExtension -ext WixUtilExtension -cultures:!culture!;de-de NCMsiHelper.wixobj WinShellExt.wixobj collect.wixobj Nextcloud.wixobj RegistryCleanupCustomAction.wixobj UinstallOldClientDlg.wixobj -out "!culture!_@MSI_INSTALLER_FILENAME@"
125125
if %ERRORLEVEL% neq 0 exit %ERRORLEVEL%
126126

127127
if NOT "!culture!" == "en-us" (

0 commit comments

Comments
 (0)