Save the script below into the ~/Libraries/Script Libraries folder with the name shutdownStore
use AppleScript version "2.3"
use scripting additions
property shutDownCacheName : "shutdownStore"
property shutdownCache : missing value
to saveShutDownStatus(theShutDownStatus)
set cachePath to ((path to library folder from user domain as text) & "caches:" & "net.mcusr." & my shutDownCacheName)
set shutdown of my shutdownCache to theShutDownStatus
store script my shutdownCache in cachePath replacing yes
end saveShutDownStatus
on loadShutDownStatusFromScriptCache()
set cachePath to ((path to library folder from user domain as text) & "caches:" & "net.mcusr." & my shutDownCacheName)
local script_cache
try
set my shutdownCache to load script alias cachePath
on error
script newScriptCache
property shutdown : false
end script
set my shutdownCache to newScriptCache
end try
return shutdown of my shutdownCache
end loadShutDownStatusFromScriptCache
on getShutDownStatus()
set last_shutDownStatus to loadShutDownStatusFromScriptCache()
return last_shutDownStatus
end getShutDownStatus
Use this from your scripts like I have modified them:
First Script:
use AppleScript version "2.3"
use scripting additions
use mss : script "shutdownStore"
set msshutdown to yes
saveShutDownStatus(msshutdown) of mss
tell application "Finder"
shut down
end tell
Second Script:
use AppleScript version "2.3"
use scripting additions
use mss : script "shutdownStore"
set msshutdown to getShutDownStatus() of mss
if msshutdown is yes then
tell application "MainStage 3"
activate
end tell
set msshutdown to no
saveShutDownStatus(msshutdown) of mss
end if