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:
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.