PortValhalla/scripts/Windows/Config/Thunderbird/Install.ps1

39 lines
1.1 KiB
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 Thunderbird the default Mail 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")) {
switch ($association.Identifier) {
"mailto" {
$association.ApplicationName = "Thunderbird";
$association.ProgId = "Thunderbird.Url.mailto";
};
".eml" {
$association.ApplicationName = "Thunderbird";
$association.ProgId = "ThunderbirdEML";
};
}
}
$defaultAssociations.Save($configFile);
DISM /Online "/Import-DefaultAppAssociations:$configFile";
Pop-Location;
Remove-Item -Recurse $tempDir;