Forráskód Böngészése

integrate script into installer

Armin Schrenk 2 éve
szülő
commit
e56e6a8359

+ 4 - 0
dist/win/contrib/version170-migrate-settings.bat

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

+ 8 - 4
dist/win/contrib/170FuseMigration.ps1

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

+ 4 - 0
dist/win/resources/main.wxs

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