Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Reset Firefox preserving bookmarks on many machines Web Browsers
Sometimes, Firefox bounces in the Dock and will not open. Either a new Firefox version has been pushed out to the machine, or some Firefox settings have changed. If it's on a personal machine, it's pretty easy to handle. What if it happens on a corporate network with many users, and you must repair them all?

Here is a solution so that a user clicks on the Scripts menu in the menu bar and selects a script from a drop down menu called Reset Firefox.

A pop-up dialog box asks the user 'Do you wish to reset Firefox,' with Yes and No buttons. The user clicks Yes and another dialog pops up 'Just leave the script to do its stuff. Firefox will open with instructions on how to restore your Bookmarks.' with an OK button.

The user clicks OK and waits, and after a short period, Firefox opens as a new user would see it asking the normal setup questions like do you wish to import anything, set the default browser, etc. Then a web page automatically opens which is a Mozilla KB article telling them how to reset their bookmarks.

How to set it up:
  • Open Terminal and elevate user privileges to a local admin account if already not.

    su admin

  • Elevate user privileges to root.

    sudo su

  • Navigate to or create the directory:

    mkdir /Library/Management/Scripts

  • Create a script called

    touch /Library/Management/Scripts/

  • Add contents to the script:

    vi /Library/Management/Scripts/ Press key 'i' for insert and insert the following:
    # Quitting Firefox
    killall firefox-bin
    # Removing previous Firefox_bookmarkbackups
    rm -rf ~/Documents/Firefox_bookmarkbackups
    # Pausing 3 seconds
    sleep 3
    # Making a backup directory
    mkdir ~/Documents/Firefox_bookmarkbackups
    # Making a temp direcory
    mkdir ~/Temp
    # Pausing 3 seconds
    sleep 3
    # Find the users bookmarkbackups and move them to the temp directory
    Find -x ~/Library/Application Support/Firefox/Profiles/********.default/ -name 'bookmarkbackups' -print0 | xargs -0 -I bookmarkbackups cp -R bookmarkbackups ~/Temp/
    # Pausing 3 seconds
    sleep 3
    # Copy the bookmarkbackups to the Firefox_bookmarkbackups directory
    cp -R ~/Temp/bookmarkbackups ~/Documents/Firefox_bookmarkbackups/
    # Pausing 5 seconds
    sleep 5
    # Deleting the FireFox app data
    rm -rf ~/Library/Application Support/Firefox
    # Removing the users Firefox cache
    rm -rf ~/Library/Caches/Firefox
    # Pausing 5 seconds
    sleep 5
    # Launch Firefox
    open /Applications/
    # Pausing 10 seconds
    sleep 10
    # Moving the bookmarkbackups from the temp to the users new app data location
    Find -x ~/Library/Application Support/Firefox/Profiles/ -name '********.default' -print0 | xargs -0 -I folder mv ~/Temp/bookmarkbackups/ folder
    # Pausing 3 seconds
    sleep 3
    # Removing the temp directory
    rm -rf ~/Temp
    # Opening the web page for instructions to recover bookmarks
    open /Applications/
  • To save the changes press keys 'Shift' and ':' and type wq!.
  • Set the permissions on the script so that other users will be able to execute it

    chmod -R 775 /Library/Management/

  • Package up the script with you favourite packaging tools ready for mass deployment to machines. A good one is Composer by JAMF Software.
  • Open up Script editor and paste in the following
    display dialog "Do you wish to reset Firefox? You will be able to recover bookmarks following instructions from the opening page." buttons {"No", "Yes"} default button "Yes"
    if button returned of result is "Yes" then
        display dialog "Please wait for the script to do its stuff and Firefox should open automatically."
        if button returned of result is "OK" then
            do shell script "/Library/Management/Scripts/"
        end if
    end if
  • Save the script calling it Reset Firefox to /Library/Scripts/xxx as a run only script, where xxx could be a custom folder name such as your company name, or simply 'Firefox.' It is advisable to keep an editable copy of the script for your reference only calling it Editable_Reset_Firefox and save it somewhere else.
  • Change permissions so that all user can execute the AppleScript as before doing it through terminal as root (where xxx is the name you used in the previous step):

    Chmod -R 775 /Library/Scripts/xxx/

  • Package up the script with you packaging tools ready for mass deployment to machines.

One problem is you need the Scripts menu showing in every users screen on all the machines in the company. To do this we use mcx with Apples Workgroup manager.

Open AppleScript Editor and go to Preferences and tick the box 'Show scripts menu in the Menu bar.'

Navigate to your Preferences directory and copy the file to your desktop and using Property list editor (which comes with Apple's Developer Tools) open it and make sure you have under the menuExtras key the entry /System/Library/CoreServices/Menu Extras/Script and save it.

Add the to all Computer Groups in Workgroup Manager and when importing it select always.

Next time the machines reboot it will be in the users Menu bar always and you can just publish simple instructions on your company's intranet. This way if a user has a problem just point them to the Intranet page and let them do it.

[crarko adds: I haven't tested this one. Obviously this is targeted to enterprise deployment and it's complete overkill to do all of this for just a few machines. Still, it's good to see hints sometimes aimed at the large-scale network. If it were me, I'd skip the steps using vi and create the script using BBEdit or TextWrangler.

P.S. This was a very complex hint to edit so if there are errors please let me know in the comments so I can fix them.]
  • Currently 4.50 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)

Reset Firefox preserving bookmarks on many machines | 2 comments | Create New Account
Click here to return to the 'Reset Firefox preserving bookmarks on many machines' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Reset Firefox preserving bookmarks on many machines
Authored by: macsadmn on Mar 10, '11 07:39:34AM

Nice hint!

It's good to know that others have experienced this same issue with FireFox.

I took what you made and tweaked/added a few things that may be beneficial:

Instead of directing your users to the Mozilla webpage on how to recover their bookmarks, you can add these lines to the bottom of your shell script that will force FireFox to reimport the backed up bookmarks:


# Quitting Firefox
killall firefox-bin

# Pausing 3 seconds
sleep 2

# Remove places.sqlite, if it was created
# This will force FireFox to automatically recover bookmarks from backup
rm ~/Library/Application\ Support/Firefox/Profiles/********.default/places.sqlite

# Pausing 3 seconds
sleep 2

# Launch Firefox
open /Applications/

# Pausing 5 seconds
sleep 5


To alert users when the script has finished, I added the following lines immediately after your "do shell script" statement in the AppleScript:

tell application "System Events" to activate
tell application "System Events" to display dialog " !!!!! FireFox Reset Complete !!!! "

Again, thank you for posting the hint. Well done!

[ Reply to This | # ]
Reset Firefox preserving bookmarks on many machines
Authored by: alangbaker on Mar 10, '11 12:53:44PM
You've made this rather more complex than it needs to be. The only file you need to remove is the invisible (in the Finder) file ".parentlock". Simply make sure that Firefox isn't running, then:
find ~/Application Support/Firefox/Profiles/ -name .parentlock -exec rm {} \;
That's the gist, anyway.

[ Reply to This | # ]