integrate script into installer

This commit is contained in:
Armin Schrenk
2023-01-31 13:58:56 +01:00
parent 5f9b77241f
commit e56e6a8359
3 changed files with 16 additions and 4 deletions

View File

@@ -0,0 +1,4 @@
@echo off
cd %~dp0
powershell -NoLogo -NonInteractive -ExecutionPolicy Unrestricted -Command .\version170-migrate-settings.ps1

View File

@@ -1,4 +1,5 @@
# This script migrates Cryptomator settings for all local users on Windows in case a custom directory is used
# This script migrates Cryptomator settings for all local users on Windows in case the users uses custom directories as mountpoint
#
#Requires -RunAsAdministrator
#Get all active, local user profiles
@@ -6,11 +7,14 @@ $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 {
$matches = ($_ | Select-String -Pattern "\\([^\\]+)$").Matches
if($matches.Count -eq 1) {
$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($matches[0].Groups[1].Value)
} else {
return $false;
}
return $false;
} | ForEach-Object {
$settingsPath = "$_\AppData\Roaming\Cryptomator\settings.json"
if(!(Test-Path -Path $settingsPath)) {

View File

@@ -132,6 +132,9 @@
<!-- WebDAV patches -->
<CustomAction Id="PatchWebDAV" Impersonate="no" ExeCommand="[INSTALLDIR]patchWebDAV.bat" Directory="INSTALLDIR" Execute="deferred" Return="asyncWait" />
<!-- Special Settings migration for 1.7.0 -->
<CustomAction Id="170MigrateSettings" Impersonate="no" ExeCommand="[INSTALLDIR]version170-migrate-settings.bat" Directory="INSTALLDIR" Execute="deferred" Return="asyncWait" />
<!-- Running App detection and exit -->
<Property Id="FOUNDRUNNINGAPP" Admin="yes"/>
<util:CloseApplication
@@ -182,6 +185,7 @@
<RemoveExistingProducts After="InstallValidate"/>
<Custom Action="PatchWebDAV" After="InstallFiles">NOT Installed OR REINSTALL</Custom>
<Custom Action="170MigrateSettings" After="InstallFiles">NOT Installed OR REINSTALL</Custom>
</InstallExecuteSequence>
<WixVariable Id="WixUIBannerBmp" Value="$(env.JP_WIXWIZARD_RESOURCES)\banner.bmp" />