Skip to content

Instantly share code, notes, and snippets.

@sdovnic
Created September 1, 2019 22:44
Show Gist options
  • Save sdovnic/9d4c158b23f2fefdec4bbe03846cbebb to your computer and use it in GitHub Desktop.
Save sdovnic/9d4c158b23f2fefdec4bbe03846cbebb to your computer and use it in GitHub Desktop.
$MozillaId = ((Get-Item -Path "HKLM:\\SOFTWARE\Classes\FirefoxHTML-*" | Select-Object -Property Name -First 1).Name).Split("-")[1]
$InstallsFile = Get-Content -Path $env:APPDATA\Mozilla\Firefox\installs.ini
$InstallsMatch = $InstallsFile -match "\[(.*)\]"
if ($InstallsMatch -ne ("[{0}]" -f $MozillaId)) {
$false
("[{0}]" -f $MozillaId)
$InstallsMatch
} else {
$InstallsFile -replace "\[(.*)\]", ("[{0}]" -f $MozillaId) | Set-Content -Path $env:APPDATA\Mozilla\Firefox\installs.ini
}
$ProfilesFile = Get-Content -Path $env:APPDATA\Mozilla\Firefox\profiles.ini
$ProfilesMatch = $ProfilesFile -match "\[Install(.*)\]"
if ($ProfilesMatch -ne ("[Install{0}]" -f $MozillaId)) {
$false
("[Install{0}]" -f $MozillaId)
$ProfilesMatch
} else {
$ProfilesFile -replace "\[Install(.*)\]", ("[Install{0}]" -f $MozillaId) | Set-Content -Path $env:APPDATA\Mozilla\Firefox\profiles.ini
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment