diff --git a/dist/win/contrib/version170-migrate-settings.bat b/dist/win/contrib/version170-migrate-settings.bat new file mode 100644 index 000000000..94ec16dac --- /dev/null +++ b/dist/win/contrib/version170-migrate-settings.bat @@ -0,0 +1,5 @@ +@echo off +:: see comments in file ./version170-migrate-settings.ps1 + +cd %~dp0 +powershell -NoLogo -NonInteractive -ExecutionPolicy Unrestricted -Command .\version170-migrate-settings.ps1 \ No newline at end of file diff --git a/dist/win/contrib/version170-migrate-settings.ps1 b/dist/win/contrib/version170-migrate-settings.ps1 new file mode 100644 index 000000000..11b9e29e3 --- /dev/null +++ b/dist/win/contrib/version170-migrate-settings.ps1 @@ -0,0 +1,45 @@ +# This script migrates Cryptomator settings for all local users on Windows in case the users uses custom directories as mountpoint +# See also https://github.com/cryptomator/cryptomator/pull/2654. +# +# TODO: This script should be evaluated in a yearly interval if it is still needed and if not, should be removed +# +#Requires -RunAsAdministrator + +#Get all active, local user profiles +$profileList = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList' +$localUsers = Get-LocalUser | Where-Object {$_.Enabled} | ForEach-Object { $_.Name} + +Get-ChildItem $profileList | ForEach-Object { $_.GetValue("ProfileImagePath") } | Where-Object { + $profileNameMatches = ($_ | Select-String -Pattern "\\([^\\]+)$").Matches + if($profileNameMatches.Count -eq 1) { + #check if the last path part is contained in the local user name list + #otherwise do not touch it + return $localUsers.Contains($profileNameMatches[0].Groups[1].Value) + } else { + return $false; + } +} | ForEach-Object { + $settingsPath = "$_\AppData\Roaming\Cryptomator\settings.json" + if(!(Test-Path -Path $settingsPath -PathType Leaf)) { + #No settings file, nothing to do. + return; + } + $settings = Get-Content -Path $settingsPath | ConvertFrom-Json + if($settings.preferredVolumeImpl -ne "FUSE") { + #Fuse not used, nothing to do + return; + } + + #check if customMountPoints are used + $atLeastOneCustomPath = $false; + foreach ($vault in $settings.directories){ + $atLeastOneCustomPath = $atLeastOneCustomPath -or ($vault.useCustomMountPath -eq "True") + } + + #if so, use WinFsp Local Drive + if( $atLeastOneCustomPath ) { + Add-Member -Force -InputObject $settings -Name "mountService" -Value "org.cryptomator.frontend.fuse.mount.WinFspMountProvider" -MemberType NoteProperty + $newSettings = $settings | Select-Object * -ExcludeProperty "preferredVolumeImpl" + ConvertTo-Json $newSettings | Set-Content -Path $settingsPath + } +} diff --git a/dist/win/resources/main.wxs b/dist/win/resources/main.wxs index d6247bf05..1fb7b552d 100644 --- a/dist/win/resources/main.wxs +++ b/dist/win/resources/main.wxs @@ -132,6 +132,9 @@ + + + NOT Installed OR REINSTALL + NOT Installed OR REINSTALL