Import-Module BitsTransfer $ProgramName = "*Mozilla*Firefox*" $installPath = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" | Where-Object { $_.getValue('DisplayName') -like $ProgramName } | ForEach-Object { $_.getValue('InstallLocation')} if (!$installPath) { # Choose firefox flavor write-host "" write-host "1 - Download Firefox" write-host "2 - Download Firefox Extended Support Release" write-host "" write-host "E - Exit" write-host "" write-host -nonewline "Type your choice and press Enter: " $choice = read-host switch -Regex ( $choice ) { 1 { Write-Host "Firefox" -ForegroundColor Green; $url = "https://download.mozilla.org/?product=firefox-latest-ssl&os=win"} 2 {Write-Host "Firefox ESR" -ForegroundColor Green; $url = "https://download.mozilla.org/?product=firefox-esr-latest-ssl&os=win"} default { exit } } if ([IntPtr]::size -eq 8) { # Check if the system is 64bit and download the correct version $url += "64" } $downloadfile = "\FirefoxInstaller.exe" Write-Output "Downloading firefox..." Start-BitsTransfer -Source $url -Destination $downloadfile Write-Output "" Write-Output "Installing Firefox. Please, follow the wizard" Start-Process $downloadfile -NoNewWindow -Wait # Check if firefox is running and kill while ($firefox = Get-Process firefox -ErrorAction SilentlyContinue) { $firefox | Stop-Process -Force Sleep 3 } # Check if firefox is installed Remove-Item $downloadfile $installPath = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" | Where-Object { $_.getValue('DisplayName') -like $ProgramName } | ForEach-Object { $_.getValue('InstallLocation')} if (!$installPath) { Write-Output "Firefox can't be located. Process can't continue" exit } } else {Write-Host "Firefox is installed" } # Check if firefox is running and kill while ($firefox = Get-Process firefox -ErrorAction SilentlyContinue) { $firefox | Stop-Process -Force Sleep 3 } Write-Output "Delete files with privacy....." Remove-Item -Path $installPath\crashreporter.exe -Force Remove-Item -Path $installPath\updater.exe -Force Remove-Item -Path $installPath\pingsender.exe -Force Write-Output "Extra privacy..." $bytes = [System.IO.File]::ReadAllBytes("$installPath\omni.ja") $hexString = [System.BitConverter]::ToString($bytes) $offset = $hexString.IndexOf("3F-20-22-68-74-74-70-73-3A-2F-2F-66-69-72-65-66-6F-78-2E-73-65-74-74-69-6E-67-73-2E-73-65-72-76-69-63-65-73-2E-6D-6F-7A-69-6C-6C-61-2E-63-6F") $offset = $offset/3 $bytes[$offset+3] = 34 # write " $bytes[$offset+4] = 59 # write ; $bytes[$offset+5] = 47 # write / $bytes[$offset+6] = 47 # write / [System.IO.File]::WriteAllBytes("C:\Program Files\Mozilla Firefox\omni2.ja", $bytes) Remove-Item -Path $installPath\omni.ja -Force Rename-Item -Path $installPath\omni2.ja omni.ja Write-Output "Copy librewolf settings" $scriptPath = Split-Path -Path $MyInvocation.MyCommand.Path Copy-Item "$scriptPath\settings\*" -Destination "$installPath" -Recurse -Force Write-Output "Enjoy"