Home / Tutorials / Disable “Reopen Windows When Logging Back In” in Mac OS X Lion Completely

Disable “Reopen Windows When Logging Back In” in Mac OS X Lion Completely

You may have noticed that when you log out or reboot Mac OS X Lion, you get a dialog window with a checkbox next to “Reopen windows when logging back in” that restores all of your currently open applications and windows.

disable-reopen-windows

If you don’t like it and you’re tired of unchecking the box to no longer reopen the windows, you can use a third party script to render the feature useless. To clarify, what this does is disable the feature completely on a constant basis, regardless of whether that checkbox to preserve windows is checked or not, the windows will not restore.

While this is part of OS X Lion’s Resume feature, this is different than disabling app Resume completely or on a per application basis, because this only effects reboots and logouts.

Turning Off “Reopen windows when logging back in” by Making it Useless

Remember, this script disables the feature, but the dialog window will still pop up. The difference is with this script, it won’t matter if the dialog box is checked or not, windows and apps will not restore.

Paste the following into a single line within the Terminal:

curl http://goo.gl/Z4EFC -L -s -o ~/fixlogin.sh && chmod +x ~/fixlogin.sh && sudo ~/fixlogin.sh ; rm ~/fixlogin.sh

(The above text is intentionally small so that it will fit on a single line)

That command downloads a script, places it in the appropriate location, makes it executable, and then removes the temporary file. If you are wondering, the contents of the downloaded bash script are the following:

#!/bin/bash
echo "#!/bin/bash" > /tmp/loginfix.sh
echo "rm /Users/*/Library/Preferences/ByHost/com.apple.loginwindow.*" >> /tmp/loginfix.sh
mv /tmp/loginfix.sh /usr/bin/loginfix.sh
chmod +x /usr/bin/loginfix.sh
defaults write com.apple.loginwindow LoginHook /usr/bin/loginfix.sh

If you ever want to revert back to the default behavior of this OS X Lion feature, just type the following defaults write command:

sudo defaults delete com.apple.loginwindow LoginHook

And you’ll be back to be able to select window restore based on that checkbox’s choice.

This little script comes from HexBrain, thanks for sending this in Mark!

Download Full Version

About J8mesz

I don't strive to be #1, but to be the only one.

Leave a Reply