Refactor Firefox config script
This commit is contained in:
parent
85a665fa08
commit
2530c5dc6b
1 changed files with 8 additions and 37 deletions
|
@ -1,22 +1,7 @@
|
||||||
#!/bin/pwsh
|
#!/bin/pwsh
|
||||||
param($context)
|
. "$PSScriptRoot/../../Scripts/AppAssociations.ps1";
|
||||||
|
$progIdSuffix = "-308046B0AF4A39CB";
|
||||||
. "$PSScriptRoot/../../Scripts/Context.ps1";
|
$appName = "Firefox";
|
||||||
|
|
||||||
[Context] $context = $context;
|
|
||||||
$tempDir = $context.GetTempDirectory();
|
|
||||||
|
|
||||||
Push-Location $tempDir;
|
|
||||||
$configFile = "$tempDir/DefaultAssociations.xml";
|
|
||||||
|
|
||||||
Write-Information "Making Firefox the default browser";
|
|
||||||
DISM /Online "/Export-DefaultAppAssociations:$configFile";
|
|
||||||
|
|
||||||
[xml]$defaultAssociations = [xml]::new();
|
|
||||||
$defaultAssociations.PreserveWhitespace = $true;
|
|
||||||
$reader = [System.Xml.XmlReader]::Create("$configFile", $readerSettings);
|
|
||||||
$defaultAssociations.Load($reader);
|
|
||||||
$reader.Dispose();
|
|
||||||
|
|
||||||
$extensions = @(
|
$extensions = @(
|
||||||
".htm",
|
".htm",
|
||||||
|
@ -32,24 +17,10 @@ $schemes = @(
|
||||||
"https"
|
"https"
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($association in $defaultAssociations.SelectNodes("/DefaultAssociations/Association")) {
|
foreach ($extension in $extensions) {
|
||||||
[string] $className = $null;
|
Set-DefaultAppAssociation $extension "FirefoxHTML$progIdSuffix" $appName;
|
||||||
|
|
||||||
if (($extensions + $schemes) -contains $association.Identifier) {
|
|
||||||
$association.ApplicationName = "Firefox";
|
|
||||||
|
|
||||||
if ($extensions -contains $association.Identifier) {
|
|
||||||
$className = "FirefoxHTML";
|
|
||||||
} else {
|
|
||||||
$className = "FirefoxURL";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$association.ProgId = "$className-308046B0AF4A39CB";
|
foreach ($scheme in $schemes) {
|
||||||
|
Set-DefaultAppAssociation $scheme "FirefoxURL$progIdSuffix" $appName;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$defaultAssociations.Save($configFile);
|
|
||||||
DISM /Online "/Import-DefaultAppAssociations:$configFile";
|
|
||||||
|
|
||||||
Pop-Location;
|
|
||||||
Remove-Item -Recurse $tempDir;
|
|
||||||
|
|
Loading…
Reference in a new issue