From 9f4a7c8cce67a9eede779fb97897de3f04507cac Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Wed, 1 Dec 2021 12:28:23 +0100 Subject: [PATCH 1/2] renamed scripts --- dist/win/contrib/{patchHosts.bat => patchWebDAV.bat} | 2 +- dist/win/contrib/{patchHosts.ps1 => patchWebDAV.ps1} | 0 dist/win/resources/main.wxs | 5 +++-- 3 files changed, 4 insertions(+), 3 deletions(-) rename dist/win/contrib/{patchHosts.bat => patchWebDAV.bat} (75%) rename dist/win/contrib/{patchHosts.ps1 => patchWebDAV.ps1} (100%) diff --git a/dist/win/contrib/patchHosts.bat b/dist/win/contrib/patchWebDAV.bat similarity index 75% rename from dist/win/contrib/patchHosts.bat rename to dist/win/contrib/patchWebDAV.bat index 6363b3e33..e31249831 100644 --- a/dist/win/contrib/patchHosts.bat +++ b/dist/win/contrib/patchWebDAV.bat @@ -1,3 +1,3 @@ @echo off cd %~dp0 -powershell -NoLogo -NonInteractive -ExecutionPolicy Unrestricted -Command .\patchHosts.ps1 \ No newline at end of file +powershell -NoLogo -NonInteractive -ExecutionPolicy Unrestricted -Command .\patchWebDAV.ps1 \ No newline at end of file diff --git a/dist/win/contrib/patchHosts.ps1 b/dist/win/contrib/patchWebDAV.ps1 similarity index 100% rename from dist/win/contrib/patchHosts.ps1 rename to dist/win/contrib/patchWebDAV.ps1 diff --git a/dist/win/resources/main.wxs b/dist/win/resources/main.wxs index 8a0123a57..4954e1ea8 100644 --- a/dist/win/resources/main.wxs +++ b/dist/win/resources/main.wxs @@ -124,7 +124,8 @@ - + + @@ -156,7 +157,7 @@ - NOT Installed OR REINSTALL + NOT Installed OR REINSTALL From eee672f9eefd65805365c8ebab5eba218428c410 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Wed, 1 Dec 2021 13:53:33 +0100 Subject: [PATCH 2/2] closes #1932, closes #1931 --- dist/win/contrib/patchWebDAV.ps1 | 63 +++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 9 deletions(-) diff --git a/dist/win/contrib/patchWebDAV.ps1 b/dist/win/contrib/patchWebDAV.ps1 index bab50cc63..51b063560 100644 --- a/dist/win/contrib/patchWebDAV.ps1 +++ b/dist/win/contrib/patchWebDAV.ps1 @@ -1,16 +1,61 @@ #Requires -RunAsAdministrator -$sysdir = [Environment]::SystemDirectory -$hostsFile = "$sysdir\drivers\etc\hosts" -$aliasLine = '127.0.0.1 cryptomator-vault' +# Adds for address 127.0.0.1 the 'cryptomator-vault' alias to the hosts file +function Add-AliasToHost { + $sysdir = [Environment]::SystemDirectory + $hostsFile = "$sysdir\drivers\etc\hosts" + $aliasLine = '127.0.0.1 cryptomator-vault' -foreach ($line in Get-Content $hostsFile) { - if ($line -eq $aliasLine){ - Write-Output 'No changes necessary' - exit 0 + foreach ($line in Get-Content $hostsFile) { + if ($line -eq $aliasLine){ + return + } } + + Add-Content -Path $hostsFile -Encoding ascii -Value "`r`n$aliasLine" } -Add-Content -Path $hostsFile -Encoding ascii -Value "`r`n$aliasLine" -Write-Output 'Added alias to hosts file' + +# Sets in the registry the webclient file size limit to the maximum value +function Set-WebDAVFileSizeLimit { + # Set variables to indicate value and key to set + $RegistryPath = 'HKLM:\SYSTEM\CurrentControlSet\Services\WebClient\Parameters' + $Name = 'FileSizeLimitInBytes' + $Value = '0xffffffff' + + # Create the key if it does not exist + If (-NOT (Test-Path $RegistryPath)) { + New-Item -Path $RegistryPath -Force | Out-Null + } + + # Now set the value + New-ItemProperty -Path $RegistryPath -Name $Name -Value $Value -PropertyType DWORD -Force | Out-Null +} + + +# Changes the network provider order such that the builtin Windows webclient is always first +function Edit-ProviderOrder { + $RegistryPath = 'HKLM:\SYSTEM\CurrentControlSet\Control\NetworkProvider\HwOrder' + $Name = 'ProviderOrder' + $WebClientString = 'webclient' + + $CurrentOrder = (Get-ItemProperty $RegistryPath $Name).$Name + + $OrderWithoutWebclientArray = $CurrentOrder -split ',' | Where-Object {$_ -ne $WebClientString} + $WebClientArray = @($WebClientString) + + $UpdatedOrder = ($WebClientArray + $OrderWithoutWebclientArray) -join "," + New-ItemProperty -Path $RegistryPath -Name $Name -Value $UpdatedOrder -PropertyType String -Force | Out-Null +} + + +Add-AliasToHost +Write-Output 'Ensured alias exists in hosts file' + +Set-WebDAVFileSizeLimit +Write-Output 'Set WebDAV file size limit' + +Edit-ProviderOrder +Write-Output 'Ensured correct provider order' + exit 0