22

How do I disable both the "relaunch apps after reboot" feature as well as the "reopen windows at relaunch" feature? When I reboot (be it after a hard reset or reboot command) I want to be presented with a blank desktop and not everything I had open before. Also, when I open an application, I don't want the dozen things I was working on previously to open all at once.

4 Answers 4

28

If you are looking for a way to permanently disable this feature so you don't have to remember the extra "uncheck the box" step every time you turn your machine off, you can simply deny OS X access to the file it uses to store your session state.

In a terminal,

# Make the file owned by root (otherwise the OS will just replace it)
sudo chown root ~/Library/Preferences/ByHost/com.apple.loginwindow*

# Remove all permissions, so it can't be read or written to
sudo chmod 000 ~/Library/Preferences/ByHost/com.apple.loginwindow*

If you wish to undo this change later and re-enable the feature, perhaps because you've suffered brain damage and now find boot-looping amusing, simply delete this file and the OS will recreate it.

# Re-enable El Capitan's obnoxious "relaunch all the things" behavior
sudo rm -f ~/Library/Preferences/ByHost/com.apple.loginwindow*
5
  • Such a great solution. This has been annoying me for so long, but never took the time to research how to stop it permanently.
    – Brady
    Commented Dec 23, 2016 at 0:09
  • The best answer. Works on El Capitan and Sierra. Commented May 26, 2017 at 15:17
  • 2
    Upvoting now, restarting. I'll downvote if I see this window again in 2 minutes :-) Commented Jan 17, 2018 at 15:07
  • 2
    Two important additions to this solution: 1) You might need to delete and re-add an empty version of that file before changing permissions. Otherwise it will just reopen whatever windows were persisted last. 2) You might also need to change some other settings to make sure applications are not set to launch at login.
    – Chuim
    Commented Mar 23, 2018 at 18:13
  • Instead of changing the owner you can also set a write protect flag with chflags uchg ~/Library/Preferences/ByHost/com.apple.loginwindow*.
    – Bachsau
    Commented Mar 4, 2021 at 15:29
5

The approach I've had success with is basically the locked-file approach by John Smfifth, after emptying the file. The nice thing about it is that it can be done without root rights and using a simple two-line shell script:

# clear the file if it isn't empty
find ~/Library/Preferences/ByHost/ -name 'com.apple.loginwindow*' ! -size 0 -exec tee {} \; < /dev/null
# set the user immutable flag
find ~/Library/Preferences/ByHost/ -name 'com.apple.loginwindow*' -exec chflags uimmutable {} \;
1
  • After a quick dive into the find manual: the exclamation mark in the first command is a unary not that's parsed by find command, not by bash history expansion. It negates the -size 0 expression, so that only a non-empty loginwindow file is found. It could also be written as -not.
    – Joe
    Commented Feb 15, 2019 at 4:38
3

The simplest solution and the one I use, is to locate the file in finder: ~/Library/Preferences/ByHost/com.apple.loginwindow

Then either close all applications to empty the above files contents, or preferably just open the file in Text Edit and delete all contents then save it.

Then, reselect the file in finder but do not open it

Then, press the Apple key (next to space-bar) + i, or go to file menu and click "Get Info". Then under the General section of the displayed information window, check the "Locked" selection box (file is then locked).

Using this method it's much easier to enable or un-enable, as the process is much simpler to remember. Terminal code you use occasionally is not likely to be easily remembered or retrieved.

1
  • 1
    The problem is more to remember the name and location of the file of which you have to change the settings. Once you know that, for many users from a Unix background, the chmod and chown shell commands and their meaning are common knowledge, while knowing that Apple has created a "locked" setting, of which they don't know what it exactly means, is quite esoteric.
    – gpvos
    Commented Apr 3, 2018 at 10:18
0

To keep applications from opening previous documents, go to System Preferences > General and tick the Close windows when quitting an app checkbox.

enter image description here

To keep the relaunch apps after reboot from occurring, un-tick the checkbox on the Shutdown or Restart pop-up window:

enter image description here

4
  • 5
    I already have the first box checked, and I always uncheck the reopen box. But when I have to do a hard reset for whatever reason, all 50 things I had open relaunch, and I'm trying to stop that.
    – jaltair9
    Commented Mar 12, 2016 at 7:28
  • 2
    I'd concentrate on fixing whatever is causing you to have to hard reset. Right now you're asking the car mechanic to fix the horn because the brakes don't work.
    – Tetsujin
    Commented Mar 12, 2016 at 10:56
  • 3
    The problem is that MacOS will still reopen windows after a forced shut down or crash. In other words the very situations where you would least like the windows to reopen (and potentially repeat the issue)
    – ViggoV
    Commented Oct 25, 2017 at 9:45
  • 1
    @Tetsujin: my system is stable, so the need for a hard reset tends to occur irregularly and very seldom, but bugs happen, so the cause is usually a one-time issue, different each time. Nevertheless, at such a time I especially don't want the nasty surprise of the system re-opening everything.
    – gpvos
    Commented Apr 3, 2018 at 10:12

You must log in to answer this question.

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