From 87d99f8ede5502790010b1ecebfe0eb5d7a3bf45 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Mon, 24 Jul 2023 23:54:05 +0200 Subject: [PATCH] Make Thunderbird the default mail program --- .../Windows/Config/Thunderbird/Install.ps1 | 38 +++++++++++++++++++ .../Windows/Software/Thunderbird/Install.ps1 | 1 + 2 files changed, 39 insertions(+) create mode 100644 scripts/Windows/Config/Thunderbird/Install.ps1 diff --git a/scripts/Windows/Config/Thunderbird/Install.ps1 b/scripts/Windows/Config/Thunderbird/Install.ps1 new file mode 100644 index 00000000..add8a84a --- /dev/null +++ b/scripts/Windows/Config/Thunderbird/Install.ps1 @@ -0,0 +1,38 @@ +#!/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")) { + $association.ApplicationName = "Thunderbird"; + + switch ($association.Identifier) { + "mailto" { + $association.ProgId = "Thunderbird.Url.mailto"; + }; + ".eml" { + $association.ProgId = "ThunderbirdEML"; + }; + } +} + +$defaultAssociations.Save($configFile); +DISM /Online "/Import-DefaultAppAssociations:$configFile"; + +Pop-Location; +Remove-Item -Recurse $tempDir; diff --git a/scripts/Windows/Software/Thunderbird/Install.ps1 b/scripts/Windows/Software/Thunderbird/Install.ps1 index d003f24b..8b479b3f 100644 --- a/scripts/Windows/Software/Thunderbird/Install.ps1 +++ b/scripts/Windows/Software/Thunderbird/Install.ps1 @@ -5,3 +5,4 @@ param($context) [Context] $context = $context; choco install -y thunderbird; +. "$PSScriptRoot/../../Config/Thunderbird/Install.ps1" $context;