Category filter
Script to install and uninstall Mozilla Firefox on Windows devices.
Mozilla Firefox offers advanced privacy and security features, which makes it ideal for enterprise use. However, manual installation/uninstallation of the app can become a hassle when needed to be done on a large number of devices. Using Hexnode’s custom script feature, administrators can install or uninstall Firefox remotely across all deployed Windows devices.
PowerShell script
Install Firefox
To install Firefox on a Window device, use the following script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
$workdir = "c:\installer\" If (Test-Path -Path $workdir -PathType Container) { Write-Host "$workdir already exists" -ForegroundColor Red} ELSE { New-Item -Path $workdir -ItemType directory } $source = "https://download.mozilla.org/?product=firefox-latest&os=win64&lang=en-US" $destination = "$workdir\firefox.exe" if (Get-Command 'Invoke-Webrequest') { Invoke-WebRequest $source -OutFile $destination } else { $WebClient = New-Object System.Net.WebClient $webclient.DownloadFile($source, $destination) } Start-Process -FilePath "$workdir\firefox.exe" -ArgumentList "/S" Start-Sleep -s 35 rm -Force $workdir/firefox* Write-Host "Successfully installed Firefox application." |
This will download the installer file in c:\installer\
and subsequently use it to install the application on your device.
Uninstall Firefox
The following script will help you uninstall Firefox:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
try { $appExists = $true $filePath = "C:\Program Files\Mozilla Firefox\uninstall\helper.exe" if(-not(Test-Path $filePath)) { $filePath = "C:\Program Files (x86)\Mozilla Firefox\uninstall\helper.exe" if(-not(Test-Path $filePath)) { $appExists = $false } } if($appExists) { Start-Process -FilePath $filePath -ArgumentList "/s" -Wait Write-Host "Successfully uninstalled Firefox application." } else { Write-Host "Firefox is not installed on this device.”} } catch { Write-Host $_.Execption.Message } |
This will check the device for the helper application required to uninstall the application and run it to uninstall Mozilla Firefox. In case the app is not installed on the device, it will relay that Firefox is not installed on this device as output.