Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

The shutdown/restart dialog has a check-box Reopen windows when logging back in which is checked by default. I need to change its behavior to be unchecked by default. Is this possible? If yes, how can I do that?

enter image description here

share|improve this question
add comment

5 Answers

Edit: since 10.7.4, the "Reopen windows when logging back in" checkbox has stayed unchecked if you uncheck it once, so the hacks below are not needed anymore.

One option is to set the LoginwindowLaunchesRelaunchApps key to false in ~/Library/Preferences/com.apple.loginwindow.plist:

defaults write com.apple.loginwindow LoginwindowLaunchesRelaunchApps -bool false

You could also save this property list as ~/Library/LaunchAgents/logout_saves_state.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN
http://www.apple.com/DTDs/PropertyList-1.0.dtd>
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>logout_saves_state</string>
    <key>ProgramArguments</key>
    <array>
        <string>defaults</string>
        <string>write</string>
        <string>com.apple.loginwindow</string>
        <string>TALLogoutSavesState</string>
        <string>-bool</string>
        <string>false</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

Then load the property list by running launchctl load ~/Library/LaunchAgents/logout_saves_state.plist or by logging out and back in once.

TALLogoutSavesState sometimes got reset to true when I logged out and back in, so just running defaults write com.apple.loginwindow TALLogoutSavesState -bool false once wouldn't have worked.

Neither of these options actually makes the checkbox appear unchecked, but they have the same effect.

share|improve this answer
    
I found a reason to still do this on 10.7.5: the box in the Restart dialog is now unchecked by default, and state is not restored. But if I forced a reboot by holding down the hardware power button on my MacBook, it restored state. After applying this fix, when rebooting with the button, I now get a dialog upon reboot that says "You shut down because of a problem. Do you want to restore state?", so I can get a clean reboot. –  Andrew Janke Oct 18 '12 at 0:42
add comment

This has changed in Mac OS X Update Version 10.7.4.

Resolve an issue where the "Reopen windows when logging back in" setting is always enabled.

enter image description here

Here is the new option, as you can see (although it isn't proof in itself as it's easy to uncheck and then screen grab, but please trust me - I was pretty stoked when I checked out this update as this bug was really annoying me!)

enter image description here

share|improve this answer
add comment

This bug has been fixed with the Lion update 10.7.4:

The OS X Lion v10.7.4 Update includes fixes that:

Resolve an issue in which the "Reopen windows when logging back in" setting is always enabled.

enter image description here

(click here for more information)

share|improve this answer
add comment

For the record, we’re talking about this:

Screenshot

The problem is that OS X doesn’t remember if you uncheck the checkbox on the last shutdown — it will always keep the checkbox checked by default on subsequent shutdowns.

I found two different solutions for this problem, that seem to do the trick, although they aren’t ideal.

Open Terminal.app and enter the following commands:

defaults write com.apple.loginwindow TALLogoutSavesState -bool false
defaults write com.apple.loginwindow LoginwindowLaunchesRelaunchApps -bool false

This effectively disables the “reopen windows when logging back in” option, although the checkbox will still appear to be checked. You can just ignore it.

I’m afraid there’s no better solution, at least not at the moment.


It’s possible to disable Resume on a per-app basis, too.

There’s also a system setting that allows you to disable it for all apps, system-wide. Go to System PreferencesGeneral:

Screenshot

Alternatively, you can run this command in Terminal.app:

# Disable Resume system-wide
defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool false

(Taken from my .osx file.)

share|improve this answer
    
TALLogoutSavesState sometimes gets reset to true after logging out and back in though. defaults write com.apple.loginwindow TALLogoutSavesState -bool false would need to be run at login using a launchd agent or something. –  Lauri Ranta Mar 21 '12 at 12:41
    
@Lri It seems to work fine for me, even after multiple logouts/reboots, in combination with the LoginwindowLaunchesRelaunchApps setting. I remember testing the two separately, in which case I ran in to the issues you described in your answer. AFAICT, there’s something about the combination of the two settings that does the trick. –  Mathias Bynens Mar 21 '12 at 12:44
    
I just ran both again, logged out and back in twice, and defaults read com.apple.loginwindow TALLogoutSavesState returned 1. –  Lauri Ranta Mar 21 '12 at 12:48
    
TALLogoutSavesState still gets set to true by itself. But just LoginwindowLaunchesRelaunchApps -bool false alone seems to be enough to disable restoring windows. –  Lauri Ranta May 10 '12 at 17:56
add comment

No, it is always set to "on." However there does exist a script you can run, that disables the feature. The box will still be checked, but the feature will no longer function:

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

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.

Source: http://osxdaily.com/

share|improve this answer
    
You can also disable Resume for applications on a per app basis. See these answers here. –  gentmatt Dec 24 '11 at 12:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.