Windows. MSI. Unregister Nextcloud folders in SyncRootManager on uninstall.

Signed-off-by: alex-z <blackslayer4@gmail.com>
This commit is contained in:
alex-z 2021-12-27 08:59:47 +02:00 committed by Matthieu Gallien (Rebase PR Action)
parent 888cd27540
commit 237e5a942f
5 changed files with 69 additions and 2 deletions

View File

@ -26,6 +26,8 @@ install(FILES
${CMAKE_CURRENT_BINARY_DIR}/make-msi.bat
Platform.wxi
Nextcloud.wxs
RegistryCleanup.vbs
RegistryCleanupCustomAction.wxs
gui/banner.bmp
gui/dialog.bmp
DESTINATION msi/)

View File

@ -76,12 +76,16 @@
<!-- Uninstall: Remove sync folders from Explorer's Navigation Pane, only effective for the current user (home users) -->
<Custom Action="RemoveNavigationPaneEntries" After="RemoveFiles">(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
<!-- Uninstall: Cleanup the Registry -->
<Custom Action="RegistryCleanupCustomAction" After="RemoveFiles">(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
<!-- Schedule Reboot for the Shell Extensions (in silent installation mode only, or if SCHEDULE_REBOOT argument is set-->
<ScheduleReboot After="InstallFinalize">(SCHEDULE_REBOOT=1) OR NOT (UILevel=2)</ScheduleReboot>
</InstallExecuteSequence>
<!-- "Add or Remove" Programs Entries -->
<Property Id="APPNAME">$(var.AppName)</Property>
<Property Id="ARPPRODUCTICON">$(var.AppIcon)</Property>
<Property Id="ARPHELPLINK">$(var.AppHelpLink)</Property>
<Property Id="ARPURLINFOABOUT">$(var.AppInfoLink)</Property>

View File

@ -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

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<Binary Id="RegistryCleanup" SourceFile="RegistryCleanup.vbs"/>
<CustomAction Id='RegistryCleanupCustomAction' BinaryKey="RegistryCleanup" VBScriptCall="RegistryCleanup" Return="ignore" Execute="immediate"/>
</Fragment>
</Wix>

View File

@ -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
"%WIX%\bin\candle.exe" -dcodepage=1252 -dPlatform=%BuildArch% -arch %BuildArch% -dHarvestAppDir="%HarvestAppDir%" -ext WixUtilExtension NCMsiHelper.wxs WinShellExt.wxs collect.wxs Nextcloud.wxs RegistryCleanupCustomAction.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 -out "@MSI_INSTALLER_FILENAME@"
"%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@"
exit %ERRORLEVEL%