Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

stuartrozier

macrumors 6502
Original poster
Nov 12, 2011
271
8
Hello,

this might already exist but i haven't found anything yet,

im trying to find an automator script, workflow or AppleScript - to safely restart my mac, like the manual way, using the apple menu.

ive tried numerous methods, finder, tell system events, sudo etc - but - these all seem to restart the mac forcefully, ie, when it restarts the open windows haven't been closed properly, safely, and they all reopen ?

when i restart using the apple menu it seems to close my open apps gracefully and then restarts, is there a app or script that can do this do you think ?

many thanks in advance,

stuart
 
Keyboard shortcut? Control-power should give you a shutdown menu. Type R to restart, and your Mac will restart.
That would give you a normal full restart, and will properly close out all apps during the restart.
That might be more useful to you than a script, and the shutdown window gives you the choice to reopen windows automatically after the restart. That may be a box that you would want to uncheck, if you don't want windows to reopen (which also means that apps associated with those windows would relaunch as part of the restart.)
 
Keyboard shortcut? Control-power should give you a shutdown menu. Type R to restart, and your Mac will restart.
That would give you a normal full restart, and will properly close out all apps during the restart.
That might be more useful to you than a script, and the shutdown window gives you the choice to reopen windows automatically after the restart. That may be a box that you would want to uncheck, if you don't want windows to reopen (which also means that apps associated with those windows would relaunch as part of the restart.)
I've just tried this an it works great - but can it be recorded as keystrokes, or written into a script at all ?

basically - im trying to restart the computer via a command - when a file gets added to a folder - a folder process will see this and run a "restart" script to restart the mac,

thanks again
 
just curious, what would be your purpose for restarting "when a file gets added to a folder"?
Are you having a problem where the Finder doesn't register a file copied to to a folder unless you restart? (or some other situation?)
 
just curious, what would be your purpose for restarting "when a file gets added to a folder"?
Are you having a problem where the Finder doesn't register a file copied to to a folder unless you restart? (or some other situation?)
no what it is,

i use my mac in a docking station, and i don't always have the mouse or keyboard attached to it, so its always on, but sometimes i need to restart it remotely - so ive found an alexa skill, using dropbox, that writes a file to a selected dropbox folder, but using folder actions, ive managed to set it up so when the file is dropped into the folder it starts the restart process -

but, using the sudo restart command, or finder restart command, or system events command, it restarts forcefully, doesn't close the programs, and they all reopen all over the place ?

but when i use the system menu, (apple logo) to manually restart the mac - it does it gracefully, closing the open programs - and restarts to a fresh desktop with no programs open starting from scratch
 
no what it is,

i use my mac in a docking station, and i don't always have the mouse or keyboard attached to it, so its always on, but sometimes i need to restart it remotely - so ive found an alexa skill, using dropbox, that writes a file to a selected dropbox folder, but using folder actions, ive managed to set it up so when the file is dropped into the folder it starts the restart process -

but, using the sudo restart command, or finder restart command, or system events command, it restarts forcefully, doesn't close the programs, and they all reopen all over the place ?

but when i use the system menu, (apple logo) to manually restart the mac - it does it gracefully, closing the open programs - and restarts to a fresh desktop with no programs open starting from scratch
and this is what im trying to achieve but in a script, a gentle way of restarting the mac without me having to touch it
 
But, you said that you want to restart after a file gets added to a folder.
I was just trying to understand the need for that -- Why is it necessary for you to restart at that point?
How often do you really need to restart?
 
AppleScript that can be used in a QuickAction

Code:
tell application "System Events"
    restart
end tell

or

Code:
tell application "Finder"
    restart
end tell
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.