Refactor logic for setting default applications
This commit is contained in:
parent
9b1be73a7a
commit
41696d2078
2 changed files with 8 additions and 64 deletions
|
@ -1,38 +1,8 @@
|
|||
#!/bin/pwsh
|
||||
param($context)
|
||||
|
||||
. "$PSScriptRoot/../../Scripts/Context.ps1";
|
||||
|
||||
[Context] $context = $context;
|
||||
$tempDir = $context.GetTempDirectory();
|
||||
|
||||
Push-Location $tempDir;
|
||||
$configFile = "$tempDir/DefaultAssociations.xml";
|
||||
. "$PSScriptRoot/../../Scripts/AppAssociations.ps1";
|
||||
$applicationName = "Thunderbird";
|
||||
|
||||
Write-Host "Configuring Thunderbird";
|
||||
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;
|
||||
Set-DefaultAppAssociation "mailto" "Thunderbird.Url.mailto" $applicationName;
|
||||
Set-DefaultAppAssociation ".eml" "ThunderbirdEML" $applicationName;
|
||||
|
|
|
@ -1,32 +1,6 @@
|
|||
#!/bin/pwsh
|
||||
param($context)
|
||||
|
||||
. "$PSScriptRoot/../../Scripts/Context.ps1";
|
||||
|
||||
[Context] $context = $context;
|
||||
$tempDir = $context.GetTempDirectory();
|
||||
|
||||
Push-Location $tempDir;
|
||||
$configFile = "$tempDir/DefaultAssociations.xml";
|
||||
. "$PSScriptRoot/../../Scripts/AppAssociations.ps1";
|
||||
|
||||
Write-Host "Configuring WinSCP";
|
||||
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;
|
||||
Set-DefaultAppAssociation "ftp" "WinSCP.Url" "WinSCP: SFTP, FTP, WebDAV, S3 and SCP client";
|
||||
|
|
Loading…
Reference in a new issue