From: alex-z Date: Mon, 27 Dec 2021 06:59:47 +0000 (+0200) Subject: Windows. MSI. Unregister Nextcloud folders in SyncRootManager on uninstall. X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~17^2~213^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=237e5a942fc0faf1b68bf86b2410c5e2124b4f29;p=nextcloud-desktop.git Windows. MSI. Unregister Nextcloud folders in SyncRootManager on uninstall. Signed-off-by: alex-z --- diff --git a/admin/win/msi/CMakeLists.txt b/admin/win/msi/CMakeLists.txt index a51aacd8d..540bacad9 100644 --- a/admin/win/msi/CMakeLists.txt +++ b/admin/win/msi/CMakeLists.txt @@ -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/) diff --git a/admin/win/msi/Nextcloud.wxs b/admin/win/msi/Nextcloud.wxs index 7e665a862..8e694b3f6 100644 --- a/admin/win/msi/Nextcloud.wxs +++ b/admin/win/msi/Nextcloud.wxs @@ -76,12 +76,16 @@ (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL") + + + (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL") (SCHEDULE_REBOOT=1) OR NOT (UILevel=2) + $(var.AppName) $(var.AppIcon) $(var.AppHelpLink) $(var.AppInfoLink) diff --git a/admin/win/msi/RegistryCleanup.vbs b/admin/win/msi/RegistryCleanup.vbs new file mode 100644 index 000000000..50e26c8ca --- /dev/null +++ b/admin/win/msi/RegistryCleanup.vbs @@ -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 diff --git a/admin/win/msi/RegistryCleanupCustomAction.wxs b/admin/win/msi/RegistryCleanupCustomAction.wxs new file mode 100644 index 000000000..a546930e6 --- /dev/null +++ b/admin/win/msi/RegistryCleanupCustomAction.wxs @@ -0,0 +1,7 @@ + + + + + + + diff --git a/admin/win/msi/make-msi.bat.in b/admin/win/msi/make-msi.bat.in index a8c5d4946..eb1473532 100644 --- a/admin/win/msi/make-msi.bat.in +++ b/admin/win/msi/make-msi.bat.in @@ -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%