Skip to content

Commit

Permalink
Merge #148 [stable-3.12] nmc/2081-InstallerChanges - Master
Browse files Browse the repository at this point in the history
  • Loading branch information
tsdicloud committed Apr 25, 2024
2 parents ed3035f + a2b4ee9 commit bc3a00d
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 14 deletions.
2 changes: 2 additions & 0 deletions admin/win/msi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ install(FILES
Nextcloud.wxs
${CMAKE_CURRENT_BINARY_DIR}/RegistryCleanup.vbs
RegistryCleanupCustomAction.wxs
UinstallOldClientDlg.wxs
License.rtf
gui/banner.bmp
gui/dialog.bmp
DESTINATION msi/)
Binary file added admin/win/msi/License.rtf
Binary file not shown.
88 changes: 79 additions & 9 deletions admin/win/msi/Nextcloud.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
https://www.joyofsetup.com/2010/01/16/major-upgrades-now-easier-than-ever/
-->
<MajorUpgrade Schedule="afterInstallInitialize" AllowDowngrades="yes" />
<Property Id="REINSTALLMODE" Value="amus" />

<Media Id="1" Cabinet="$(var.AppShortName).cab" EmbedCab="yes" />

Expand All @@ -54,13 +53,20 @@
<RegistrySearch Id="RegistryInstallDir" Type="raw" Root="HKLM" Key="Software\$(var.AppVendor)\$(var.AppName)" Win64="no" />
</Property>

<Property Id="OLDCLIENTDIR">C:\Windows\System32\</Property>

<!-- Detect legacy NSIS installation -->
<Property Id="NSIS_UNINSTALLEXE">
<RegistrySearch Id="RegistryLegacyUninstallString" Type="file" Root="HKLM" Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\$(var.AppName)" Name="UninstallString" Win64="no">
<FileSearch Id="LegacyUninstallFileName" Name="Uninstall.exe"/>
</RegistrySearch>
</Property>

<!-- <Property Id="UNINSTALL_OLD">
<RegistrySearch Id="RegistryLegacyUninstallString" Type="file" Root="HKLM" Key="Software\Microsoft\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\$("MagentaCLOUD Software")" Name="UninstallString" Win64="no">
</RegistrySearch>
</Property>-->

<!-- Property to disable update checks -->
<Property Id="SKIPAUTOUPDATE" Value="0" />

Expand All @@ -71,6 +77,59 @@
<SetProperty Id="ExecNsisUninstaller" Value="&quot;$(var.AppShortName)&quot; &quot;[NSIS_UNINSTALLEXE]&quot;" Before="ExecNsisUninstaller" Sequence="execute" />
<SetProperty Id="RemoveNavigationPaneEntries" Value="&quot;$(var.AppName)&quot;" Before="RemoveNavigationPaneEntries" Sequence="execute" />

<!-- Detect the old client by its upgrade id -->
<!-- <Upgrade Id="21BAADEB-079C-4503-B99A-D49A34D8C525">
<UpgradeVersion OnlyDetect='no' Property='OLDFOUND'
Minimum="0.0.0.0" IncludeMinimum="yes"
Maximum='99.0.0.0' IncludeMaximum='yes' />
</Upgrade> -->
<CustomAction Id="UninstallOldClient"
Script="vbscript"
Execute="immediate">
<![CDATA[
const HKEY_CLASSES_ROOT = &H80000000
const HKEY_CURRENT_USER = &H80000001
const HKEY_LOCAL_MACHINE = &H80000002
const HKEY_USERS = &H80000003
const HKEY_CURRENT_CONFIG = &H80000004
const HKEY_DYN_DATA = &H80000005
strComputer = "."
oldClientExists = False
userName = CreateObject("WScript.Network").UserName
configPath = "C:\Users\"& userName &"\AppData\Roaming\MagentaCLOUD"
configFile = configPath & "\magentacloud.cfg"
jsonPath = "C:\Users\"& userName &"\AppData\Local\MagentaCLOUD"
jsonFile = jsonFile & "\magentacloud.cfg"
set oWsh = createobject("wscript.shell")
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\default:StdRegProv")
strKeyPath = "software\WOW6432Node\microsoft\windows\currentversion\uninstall" ' Root level
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each subkey In arrSubKeys
on error resume next
sDisplayName = oWsh.Regread("HKLM\" & strKeyPath & "\" & subkey & "\DisplayName")
if err.number = 0 then
on error goto 0
if sDisplayName = "MagentaCLOUD Software" then
oldClientExists = True
sUninstall = oWsh.Regread("HKLM\" & strKeyPath & "\" & subkey & "\UnInstallString")
End If
End If
Next
on error goto 0
if oldClientExists Then
sUninstall = sUnInstall & " /qn"
command = "/k " & sUninstall
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "cmd.exe", command, "", "runas", 0
End If
]]>
</CustomAction>
<InstallExecuteSequence>
<!-- Install: Remove previous NSIS installation, if detected -->
<Custom Action="ExecNsisUninstaller" Before="ProcessComponents">NSIS_UNINSTALLEXE AND NOT Installed</Custom>
Expand Down Expand Up @@ -114,18 +173,27 @@
-->

<!-- Custom license -->
<!--
<WixVariable Id="WixUILicenseRtf" Value="$(var.AppLicenseRtf)" />
-->

<UI>
<UIRef Id="WixUI_FeatureTree" />
<UIRef Id="WixUI_ErrorProgressText" />

<!-- Skip the license page -->
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="CustomizeDlg" Order="3">1</Publish>
<!-- Skip the page on the way back too -->
<Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="3">1</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="LicenseAgreementDlg" Order="3">1</Publish>
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="CustomizeDlg" Order="3">1</Publish>
<Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg" Order="3">1</Publish>

<!-- <Publish Dialog="MigrationDialog"
Control="Finish"
Event="DoAction"
Value="RemoveOldClient">NOT Installed</Publish> -->

<!-- <Publish Dialog="MigrationDialog" Control="cancelButton" Event="EndDialog" Value="ExitDialog">1</Publish> -->
<UIRef Id="MigrationDialogUI"/>

<Publish Dialog="MigrationDialog" Control="Weiter"
Event="DoAction" Value="UninstallOldClient">Not Installed</Publish>
<Publish Dialog="MigrationDialog" Control="Weiter" Event="EndDialog" Value="Return">1</Publish>

<!-- https://wixtoolset.org/documentation/manual/v3/howtos/ui_and_localization/run_program_after_install.html -->
<Publish Dialog="ExitDialog"
Expand All @@ -141,15 +209,17 @@
<!-- "Launch" checkbox -->
<Property Id="WixShellExecTarget" Value="[#MainExecutable]" />
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch $(var.AppName)" />
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="$(var.AppName) starten" />
<SetProperty Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1" Before="CostInitialize">NOT (LAUNCH=0)</SetProperty>

<!-- Components -->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="$(var.PlatformProgramFilesFolder)" Name="PFiles">
<Directory Id="INSTALLDIR" Name="$(var.AppName)">
<Directory Id="OLDCLIENTDIR" Name="UninstallString">
<!-- Shell Extensions -->
<Directory Id="ShellExtDir" />
<Directory Id="ShellExtDir" Name="shellext" />
</Directory>
</Directory>
</Directory>

Expand Down
6 changes: 3 additions & 3 deletions admin/win/msi/OEM.wxi.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<!-- App Defines -->
<?define AppName = "@APPLICATION_NAME@" ?>
<?define AppShortName = "@APPLICATION_EXECUTABLE@" ?>
<?define OldAppName = "MagentaCLOUD Software" ?>

<?define AppIcon = "@[email protected]" ?>
<?define AppExe = "@[email protected]" ?>
Expand All @@ -32,9 +33,8 @@
<?define AppCommandOpenUrlScheme = "@APPLICATION_URI_HANDLER_SCHEME@" ?>

<!-- Custom license: To use it, also remove the "Skip the license page" stuff in the <UI> section
and uncomment <WixVariable Id="WixUILicenseRtf"...
<?define AppLicenseRtf = "path\License.rtf" ?>
-->
and uncomment <WixVariable Id="WixUILicenseRtf"...-->
<?define AppLicenseRtf = "$(sys.CURRENTDIR)\License.rtf" ?>

<!-- App Version -->
<?define VerMajor = "@MIRALL_VERSION_MAJOR@" ?>
Expand Down
54 changes: 54 additions & 0 deletions admin/win/msi/RegistryCleanup.vbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
On Error goto 0

Const HKEY_LOCAL_MACHINE = &H80000002

Const strObjRegistry = "winmgmts:\\.\root\default:StdRegProv"

Function RegistryDeleteKeyRecursive(regRoot, strKeyPath)
Set objRegistry = GetObject(strObjRegistry)
objRegistry.EnumKey regRoot, strKeyPath, arrSubkeys
If IsArray(arrSubkeys) Then
For Each strSubkey In arrSubkeys
RegistryDeleteKeyRecursive regRoot, strKeyPath & "\" & strSubkey
Next
End If
objRegistry.DeleteKey regRoot, strKeyPath
End Function

Function RegistryListSubkeys(regRoot, strKeyPath)
Set objRegistry = GetObject(strObjRegistry)
objRegistry.EnumKey regRoot, strKeyPath, arrSubkeys
RegistryListSubkeys = arrSubkeys
End Function

Function GetUserSID()
Dim objWshNetwork, objUserAccount

Set objWshNetwork = CreateObject("WScript.Network")

Set objUserAccount = GetObject("winmgmts://" & objWshNetwork.UserDomain & "/root/cimv2").Get("Win32_UserAccount.Domain='" & objWshNetwork.ComputerName & "',Name='" & objWshNetwork.UserName & "'")
GetUserSID = objUserAccount.SID
End Function

Function RegistryCleanupSyncRootManager()
strSyncRootManagerKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SyncRootManager"

arrSubKeys = RegistryListSubkeys(HKEY_LOCAL_MACHINE, strSyncRootManagerKeyPath)

If IsArray(arrSubkeys) Then
arrSubkeys=Filter(arrSubkeys, Session.Property("APPNAME"))
End If
If IsArray(arrSubkeys) Then
arrSubkeys=Filter(arrSubkeys, GetUserSID())
End If

If IsArray(arrSubkeys) Then
For Each strSubkey In arrSubkeys
RegistryDeleteKeyRecursive HKEY_LOCAL_MACHINE, strSyncRootManagerKeyPath & "\" & strSubkey
Next
End If
End Function

Function RegistryCleanup()
RegistryCleanupSyncRootManager()
End Function
52 changes: 52 additions & 0 deletions admin/win/msi/UinstallOldClientDlg.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
*
* Copyright (C) by Michael Schuster <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
-->
<?include $(sys.CURRENTDIR)OEM.wxi?>
<?include $(sys.CURRENTDIR)Platform.wxi?>

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">

<!--
When to change the Product GUID:
https://www.firegiant.com/wix/tutorial/upgrades-and-modularization/
https://www.firegiant.com/wix/tutorial/upgrades-and-modularization/checking-for-oldies/
We change the Product Id for every release, to let up-/downgrading always work.
But we then should never change the UpgradeCode.
-->
<Fragment>
<UI Id="MigrationDialogUI">

<DialogRef Id="ExitDialog"/>

<Dialog Id="MigrationDialog" Width="370" Height="270" Title="$(var.AppName) $(var.PlatformBitness)">

<Control Id="Weiter" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Cancel="yes" Text="Weiter" >
<!-- <Publish Event="DoAction" Value="RemoveOldClient">updateCheckboxResult = 1 and aquisitionCheckboxResult = 1 and Not Installed</Publish>
<Publish Event="OnExit" Value="success"></Publish> -->
</Control>
<Control Id="Bitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="234" TabSkip="no" Text="!(loc.ExitDialogBitmap)" />
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Disabled="yes" Text="Back" />
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
<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." />
<Control Id="Title" Type="Text" X="135" Y="20" Width="220" Height="60" Transparent="yes" NoPrefix="yes" Text="!(loc.ExitDialogTitle)" />
</Dialog>
<InstallUISequence>
<Show Dialog="MigrationDialog" After="ExecuteAction" />
</InstallUISequence>
</UI>
</Fragment>
</Wix>
4 changes: 2 additions & 2 deletions admin/win/msi/make-msi.bat.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Rem Generate collect.wxs
if %ERRORLEVEL% neq 0 exit %ERRORLEVEL%

Rem Compile en-US (https://www.firegiant.com/wix/tutorial/transforms/morphing-installers/)
"%WIX%\bin\candle.exe" -dcodepage=1252 -dPlatform=%BuildArch% -arch %BuildArch% -dHarvestAppDir="%HarvestAppDir%" -ext WixUtilExtension NCMsiHelper.wxs WinShellExt.wxs collect.wxs Nextcloud.wxs RegistryCleanupCustomAction.wxs
"%WIX%\bin\candle.exe" -dcodepage=1252 -dPlatform=%BuildArch% -arch %BuildArch% -dHarvestAppDir="%HarvestAppDir%" -ext WixUtilExtension NCMsiHelper.wxs WinShellExt.wxs collect.wxs Nextcloud.wxs RegistryCleanupCustomAction.wxs UinstallOldClientDlg.wxs
if %ERRORLEVEL% neq 0 exit %ERRORLEVEL%

Rem Link MSI package
"%WIX%\bin\light.exe" -sw1076 -ext WixUIExtension -ext WixUtilExtension -cultures:en-us NCMsiHelper.wixobj WinShellExt.wixobj collect.wixobj Nextcloud.wixobj RegistryCleanupCustomAction.wixobj -out "@MSI_INSTALLER_FILENAME@"
"%WIX%\bin\light.exe" -sw1076 -ext WixUIExtension -ext WixUtilExtension -cultures:de-de NCMsiHelper.wixobj WinShellExt.wixobj collect.wixobj Nextcloud.wixobj UinstallOldClientDlg.wixobj RegistryCleanupCustomAction.wixobj -out "@MSI_INSTALLER_FILENAME@"

exit %ERRORLEVEL%

0 comments on commit bc3a00d

Please sign in to comment.