Set Firefox as the default browser
This commit is contained in:
parent
1d0c78f61b
commit
2f2ccbbe9d
1 changed files with 51 additions and 0 deletions
|
@ -3,6 +3,57 @@
|
||||||
|
|
||||||
function Install-Firefox {
|
function Install-Firefox {
|
||||||
param([Context] $context)
|
param([Context] $context)
|
||||||
|
|
||||||
|
$tempDir = $context.GetTempDirectory();
|
||||||
|
$configFile = "DefaultAssociations.xml";
|
||||||
|
Push-Location $tempDir;
|
||||||
|
|
||||||
Write-Host "Installing Firefox";
|
Write-Host "Installing Firefox";
|
||||||
choco install -y firefox;
|
choco install -y firefox;
|
||||||
|
|
||||||
|
Write-Information "Making Firefox the default browser";
|
||||||
|
DISM /Online "/Export-DefaultAppAssociations:DefaultAssociations.xml";
|
||||||
|
|
||||||
|
[xml]$defaultAssociations = [xml]::new();
|
||||||
|
$defaultAssociations.PreserveWhitespace = $true;
|
||||||
|
$reader = [System.Xml.XmlReader]::Create("$drive\Autounattend.template.xml", $readerSettings);
|
||||||
|
$defaultAssociations.Load($reader);
|
||||||
|
|
||||||
|
$extensions = @(
|
||||||
|
".htm",
|
||||||
|
".html",
|
||||||
|
".mht",
|
||||||
|
".mhtml",
|
||||||
|
".svg",
|
||||||
|
".xht",
|
||||||
|
".xhtml"
|
||||||
|
);
|
||||||
|
|
||||||
|
$schemes = @(
|
||||||
|
"ftp",
|
||||||
|
"http",
|
||||||
|
"https"
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($association in $defaultAssociations.SelectNodes("/DefaultAssociations/Association")) {
|
||||||
|
[string] $className = $null;
|
||||||
|
|
||||||
|
if (($extensions + $schemes) -contains $association.Identifier) {
|
||||||
|
$association.ApplicationName = "Firefox";
|
||||||
|
|
||||||
|
if ($extensions -contains $association.Identifier) {
|
||||||
|
$className = "FirefoxHTML";
|
||||||
|
} else {
|
||||||
|
$className = "FirefoxURL";
|
||||||
|
}
|
||||||
|
|
||||||
|
$association.ProgId = "$className-308046B0AF4A39CB"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$defaultAssociations.Save($configFile);
|
||||||
|
DISM /Online "/Import-DefaultAppAssociations:$configFile";
|
||||||
|
|
||||||
|
Pop-Location;
|
||||||
|
Remove-Item -Recurse $tempDir;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue