32 lines
989 B
PowerShell
32 lines
989 B
PowerShell
#!/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;
|