One of the new features in Lion is the ability of applications to resume activity at the point an application was quit. This means that when you reopen an application it will open and display all the documents you were editing in the state when you quit the application. This is obviously very useful but there are times when you may not want confidential documents automatically opened and displayed when you open an application.
Here’s an example of the script for Safari:
set statePath to POSIX path of (path to home folder) & "Library/Saved Application State/com.apple.Safari.savedState"
set quotedPath to quoted form of statePath
do shell script "test -w " & quotedPath
set current to "enabled"
set current to "disabled"
if current is "enabled" then
tell application "Finder" to delete every item of ((POSIX file statePath) as alias)
do shell script "chmod u-w " & quotedPath
display dialog "Disabled window restore for Safari" buttons "OK" default button 1
do shell script "chmod u+w " & quotedPath
display dialog "Enabled window restore for Safari" buttons "OK" default button 1
Head over to macinchem.org for a quick explanation of how to add it to your scripts menu to give you an easy place to access it.