If you’re like me — and I know you are — you sucked up a copy of OSX Lion as soon as it was on the App Store, and were immediately infuriated by the checkbox labelled “Reopen windows when logging back in”.
Why did you find it infuriating, as I do? Because you have to uncheck it every. bloody. damn. time you shut down or reboot. If you don’t, then whatever programs you had running when you shut down will “helpfully” be loaded right the hell back into RAM when you boot again.
Apparently, someone at Apple made the decision that we want our programs to reload every time we reboot, and to hell with what we think about it — because there is no way to override this checkbox setting.
There is no preference to change it.
There is no way to make it go away.
If you forget to click that checkbox on shutdown, your programs will all reload the next time you boot.
Those of us who use silicon pigs such as Adobe’s suite find this setting not merely irritating, but positively infuriating, since it adds several minutes to your system boot time.
There have been several solutions offered to deal with this. I check periodically to see if there’s been progress made. The last time I looked, I stumbled across a series of AppleScripts written by Victor Andreoni that essentially send tell commands to the Finder, ordering a shutdown and clicking the checkbox for you.
In reading his discussion of his methods, I saw that he’d found a default setting, TALLogoutSavesState, that apparently controls whether your programs reload on boot or not. Unfortunately changing that setting to 0 is not persistent; it’s rewritten to 1 on each boot. What that means is that it’s a short-lived pleasure; next time you boot your system, yep, the goddamned programs load up again.
His AppleScript solution is suitable, I think — but there’s a principle in play here, and I’ll be hell if I let my Mac tell me what to do. So in Googling for more information, I learned a couple of other things, and fired up Automator, and did this.
Description and a link to zipped files follow.
The first item in the Automator workflow is self-explanatory; you want to exit your programs gracefully before shutting down. You’re not out to kill your machine; you just want it to behave like it used to.
The second item is a pair of calls to a shell script. Basically, this is how you issue direct commands to your OSX install, without having to use the GUI. The first call is to delete (rm) a file in your home directory, contained in the Library — Preferences — ByHost folder path. (By default, your Library folder is hidden under OSX.7, probably to keep you from touching the bare wiring.)
The file that’s being removed is a preference list which stores information on what programs are running at the time the command is issued. Each program has an index entry, as well as notations for whatever document windows might be loaded. The * is a global variable character, necessary because between the words “com.apple.loginwindow.” and “.plist” there is a hexadecimal string that’s variable from system to system, and probably boot to boot. The * wildcard basically says “look for anything with this stuff at the beginning and end, and containing anything in between.”
Deleting this file will purge the system’s list of whatever might have been running when you run the workflow. It does not affect the login items you might have set for yourself, either by right-clicking their icons in the Dock and selecting Options > Open at Login, or by specifying them as login items under your Users & Groups control panel.
The second line tells the system to set the “open at login” variable to 0, effectively disabling it entirely before shutdown. I don’t know for certain that it’s necessary to do this, but I figure overkill is better than annoyance.
Finally, there’s an Applescript that tells the Finder to shut down the system. This happens immediately after all the programs have exited, without that dialog box coming up and asking you if you’re sure. It just shuts your system down immediately, without further discussion. (Essentially, this is the same as how it used to be when you’d hold down the option key and select Shut Down from the Finder menu.)
I’ve saved the workflow as both a plain workflow script, so you can see what it does for yourself, and as an application if you decide you trust me. Put it on your Dock and use it to shut your Mac down until Apple comes to its senses and realizes that not all of us have SSDs, and that sometimes we have a damned good reason for not wanting all previously running programs to load the next time we boot.
Download the package here. It’s 280 K. Go in peace.


by BRUCE
27 Aug 2011 at 11:53
HEY, THIS APP YOU MADE IS GREAT. I TOTALLY AGREE THAT WITH LION, SOME OF US MAY WANT TO CLOSE ALL PROGRAMS BEFORE SHUTTING DOWN. IS THERE A WAY TO ADD A KEYBOARD SHORTCUT TO ACTIVATE YOUR AUTOMATOR APP?
by Warren
29 Aug 2011 at 08:38
There might be. You’d basically take the automator action itself (not the program made from it) and install it as a service. You should then be able to go into your services preferences, and assign a keyboard shortcut to the service action.
by Jolion
28 Aug 2011 at 23:50
Not having to naff about with a command line was exactly why I bought my first Mac in 1984. I want to work, not code. So thank you for sparing me the pain of fathoming Automator or Terminal in order to get my machine to behave according to my needs. I’ve been hating the re-open windows checkbox every day since downloading Lion.
Now, if you can come up with a way of thoroughly kicking the heinous, intrusive dock from my screen for good, I will send you money besides my enduring regard.
Cheers,
J.
by Warren
29 Aug 2011 at 08:41
Ha! The Dock appears to be a pretty fundamental part of the Finder UI now — however, if you download OnyX, a free OSX utility, from http://www.titanium.free.fr/ , you can at least choose where it’s going to show up.
As OSX is now, you can put the Dock on the bottom, lef, or right hand side of your display; with OnyX you have slightly better refinements available to you, including setting it to be 2d rather than 3d (which will improve the performance of your Mac slightly).
by Klaus Thams
11 Sep 2011 at 08:18
Vielen Dank für diesen Beitrag und die Veröffentlichung. Beiträge wie diese machen das Internet interessant und vielseitig
by Warren
13 Sep 2011 at 11:10
Bitte sehr!
by Rod
18 Oct 2011 at 10:46
Simply genius — thanks!
Now if I could find a similar solution for chaining all my desktop wallpapers at once instead of my current work around of saving a new wallpaper with the same name each time, I would actually be back to some of the control I had BEFORE upgrading to Lion.