From 339ea4f9b78c657e6f092ca780fcdf0494a50afd Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Mon, 24 Jul 2023 23:38:58 +0200 Subject: [PATCH] Make WinSCP the default ftp program --- scripts/Windows/Config/WinSCP/Install.ps1 | 32 +++++++++++++++++++++ scripts/Windows/Software/WinSCP/Install.ps1 | 1 + 2 files changed, 33 insertions(+) create mode 100644 scripts/Windows/Config/WinSCP/Install.ps1 diff --git a/scripts/Windows/Config/WinSCP/Install.ps1 b/scripts/Windows/Config/WinSCP/Install.ps1 new file mode 100644 index 00000000..a7fc0c24 --- /dev/null +++ b/scripts/Windows/Config/WinSCP/Install.ps1 @@ -0,0 +1,32 @@ +#!/bin/pwsh +param($context) + +. "$PSScriptRoot/../../Scripts/Context.ps1"; + +[Context] $context = $context; +$tempDir = $context.GetTempDirectory(); + +Push-Location $tempDir; +$configFile = "$tempDir/DefaultAssociations.xml"; + +Write-Information "Making WinSCP the default FTP program"; +DISM /Online "/Export-DefaultAppAssociations:$configFile"; + +[xml]$defaultAssociations = [xml]::new(); +$defaultAssociations.PreserveWhitespace = $true; +$reader = [System.Xml.XmlReader]::Create("$configFile", $readerSettings); +$defaultAssociations.Load($reader); +$reader.Dispose(); + +foreach ($association in $defaultAssociations.SelectNodes("/DefaultAssociations/Association")) { + if ($association.Identifier -eq "ftp") { + $association.ProgId = "WinSCP.Url"; + $association.ApplicationName = "WinSCP: SFTP, FTP, WebDAV, S3 and SCP client"; + } +} + +$defaultAssociations.Save($configFile); +DISM /Online "/Import-DefaultAppAssociations:$configFile"; + +Pop-Location; +Remove-Item -Recurse $tempDir; diff --git a/scripts/Windows/Software/WinSCP/Install.ps1 b/scripts/Windows/Software/WinSCP/Install.ps1 index 48d92317..dcaaa75b 100644 --- a/scripts/Windows/Software/WinSCP/Install.ps1 +++ b/scripts/Windows/Software/WinSCP/Install.ps1 @@ -5,3 +5,4 @@ param($context); [Context] $context = $context; choco install -y winscp; +. "$PSScriptRoot/../../Config/WinSCP/Install.ps1" $context;