Category filter
Script to reset Firefox to default state on Windows
This document helps you with a script to reset Firefox browser on Windows devices.
Resetting a web browser helps address issues that affect its functioning. For instance, over time, web browsers may become slower due to the accumulation of stored cookies and caches. Moreover, as the users may download browser extensions to customize their needs, it could inadvertently pose a security risk if they are malicious. So, resetting the browser could eliminate such extensions and restore browser security and performance.
Mozilla Firefox is one of the popular web browsers that are known for its security, speed, and user-friendly browsing experience. Manually resetting Firefox on Windows PCs requires users to locate Firefox’s Profiles folder within its directory, delete it, and then restart the browser. But by using the PowerShell script provided below, IT administrators can easily reset Firefox to its default state using Hexnode’s “Execute Custom Script” action.
Script to reset Firefox browser on Windows
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 26 27 |
$targetUsername = "<Username>" $profilePath = "C:\Users\$targetUsername\AppData\Roaming\Mozilla\Firefox\Profiles" if (Test-Path $profilePath) { $firefoxProcesses = Get-Process -Name "firefox" -ErrorAction SilentlyContinue | Where-Object { $_.SessionId -eq (Get-Process -Name explorer).SessionId } if ($firefoxProcesses.Count -gt 0) { Write-Host "Terminating Firefox for user $targetUsername..." $firefoxProcesses | ForEach-Object { $_.Kill() } } $profilesIniPath = "C:\Users\$targetUsername\AppData\Roaming\Mozilla\Firefox\profiles.ini" Remove-Item $profilesIniPath -ErrorAction SilentlyContinue Write-Host "Firefox has been reset to its default state for user $targetUsername." } else { Write-Host "Firefox profile folder for user $targetUsername not found." } |
The script given above will fetch the username (Replace the
You can validate the working of the script by referring to the Action History tab of that corresponding device.
What happens at the device end?
Executing the script will cause Firefox to open in its default state, as if it has been opened for the first time.