I have dabbled trying to accomplish this but have not spent a lot of time researching how to do it. I have an AppleScript app that I run everyday and once done I need to quit all running apps and restart the computer. The issue is I can quit all the apps and restart the computer but when it restarts the AppleScript app comes up as running. How can I quit the AppleScript app to insure it will not re-execute on startup?
How about this?
do shell script "shutdown -r now" with administrator privileges
Thanks maro, I know how to do the restart. The issue I have when the computer completes the reboot the app shows up as still running. I need to be able to restart and quit the app so it is not back up and running at reboot time.
Are you saying the app is running after you reboot?
If yes, then either it’s a startup item or the option “Launch apps that are running” (or smth to the effect of that) is selected in the shutdown dialog at the time you restart the computer. Other than that it’s hard to figure out why the app is running.
Model: MacBook Pro
Browser: Safari 534.57.7
Operating System: macOS 10.7
tell application "System Events" to restart with state saving preference
tell application "Finder" to restart
FWIW, the AppleScript dictionary entry for the Finder “restart” command shows it as being part of the Legacy Suite with the comment:
Also, the System Events restart command has the state-saving preference, and I think that’s needed to do what the OP wants (at least in my testing). This preference is defined as:
It appears that the state-saving preference refers to the option on the restart menu to: