How to disable app relaunch and window restore in El Capitan on reboot?
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.
Solution 1:
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*
Solution 2:
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 {} \;