15

I would like to make a batch script for Firefox that restores my last session upon launching the script. I found that I could do this rather easily in Chrome with the --restore-last-session argument. I made this script and placed it along-side chrome.exe:

chrome.exe --restore-last-session

Can the same be done with Firefox? I am aware of the built-in options within the Firefox menu, but I would like to make this script so that Firefox restores instantly when I open it.

2 Answers 2

26

Your question is oddly framed.  Why do you specifically want to be able to do this from a script?  Do you just want to be able to start Firefox and restore your previous session, or do you specifically want to do this only part of the time?

Firefox has an option to restore the previous session all the time.  In “Options” / “General”, set “When Firefox starts” to “Show your windows and tabs from last time”:

Firefox “Options” / “General” page

Then just start Firefox normally, and it will restore your previous session.

2
  • 9
    Yes, I wanted Firefox to restore my session every time I run it. I skimmed past the option in my haste to figure this out. Thank you for your answer. Commented Oct 31, 2017 at 4:03
  • 5
    @Mr.Mendelli, this option is also available for Chrome. Commented Oct 31, 2017 at 9:48
6

I think the UI setting to just load your last session on start up as shown in the other answer is the best. But just in case someone absolutely needs to know how to do this with command line you can try

firefox.exe -new-tab about:sessionrestore

It's actually just a page so it can be used with the -new-tab and -new-window parameters.

1
  • Your script brings up the restore window as if Firefox unexpectedly stopped as you said, but shows no history options. I believe a session.js script needs to be defined (if possible) for the script to add the defined session as a valid option upon execution. Your script and parameters are good to know, I think I'll experiment with them and my theory just to see if this is possible with a batch script. Commented Nov 2, 2017 at 8:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .