Aug 08

The “General” PreferencePane in Lion’s ‘System Preferences’ windows contains a “Restore windows when quitting and re-opening apps” item. However, sometimes this behaviour does’t make sense – after a reboot I found, for example, that the OS X Installer had re-launched and was asking for a package to install!

This can be prevented on a per-application basis with the Terminal command:

defaults write ‹application id› NSQuitAlwaysKeepsWindows -int 0

(… with a terminating zero, not letter “o”)

This will affect the current user, or the entire system if prefixed with “sudo“. The Application ID can be found in ‘~/Library/Preferences‘ – so, for example, preventing Installer.app from automatically restarting can be achieved by executing in Terminal:

defaults write com.apple.installer NSQuitAlwaysKeepsWindows -int 0

… but this could also be used for other intentionally ephemeral applications such as TextEdit.app or, depending on your normal usage, Terminal.app.

8 Responses to “Disable Mac OS Lion’s “Restore windows” setting on an individual per-application basis”

  1. Frances Says:

    have you figured out a way to disable this globally? I don’t want any apps to resume

  2. Stuart Says:

    That I can help you with ;)

    Launch System Preferences, choose General, and the third item from the bottom is an option named “Restore windows when quitting and re-opening apps”. Untick this, and no app will open maintain state when restarted.

    I’d miss having all of my old tabs open in Safari, though…

    (You can also untick “Reopen windows when logging back in” from the Shutdown or Restart dialogs if you only want to prevent state from being restored on reboot.)

  3. Stuart Says:

    As per this Mac OS X Hints tip, you can also tell an application to resume itself after a reboot, but not to restore any previous state by using:

     defaults write ‹application id› ApplePersistenceIgnoreState YES

    Not as immediately obviously useful, granted – but I’m sure someone’s crying out for this somewhere!

  4. Ken bonner Says:

    The option to remove the “reopen windows when logging back in” doesn’t work. Whether it is checked on unchecked, it will restore everything on my computer. I really really liked that Snow Leopard closed out all of the open programs before it shut down and they stayed that way. It was a nice feature. Now to have to manually close everything is a pain. I hope they fix this bug. Having a option to remove the “reopen windows when logging back in” is nice but since it doesn’t work it is a bug

    Ken

  5. Levi Brown Says:

    Thanks for this… I just wrapped it in a nice AppleScript:

    https://github.com/levigroker/ToggleRestoreWindows

    Cheers,

    Levi

  6. Joethewalrus Says:

    I’m having the same issue Ken Bonner is. I uncheck the checkbox, but Window Restore will not turn off. A totally obnoxious bug! I thought a permission repair would do the trick, but still no dice. Not cool!

  7. Gurpree Says:

    In the case of doing this in reverse – i.e. if you want ‘restore windows’ off for most apps and want to individually set just one or two to restore, can I assume it’s the same but ending -int 1 instead?

  8. Stuart Says:

    How about this hint: Completely disable resume with:

    rm -r "~/Library/Saved Application State/*"
    chmod -R a-w "~Library/Saved Application State"

    … although a neat alternative to this latter command would be:

    chflags uimmutable "~Library/Saved Application State"

    The article linked to above also details how to permanently disable “Reopen windows when logging back in“, and some important warnings to bear in mind with any of these fixes…

Leave a Reply

%d bloggers like this: