Possible to run Automator job before shutdown (automatically)?

Subject says it all, really: I have an Autamator job that copies some files from one place to another.

I want to run this job automatically before the machine shuts down. Is this possible?

MacBook 2GHz, MacBook Pro 2.4GHz, Mac OS X (10.5.5), Nope.

Posted on Nov 23, 2008 12:55 PM

Reply
2 replies

Nov 23, 2008 3:16 PM in response to Øivind Idsø

the only way I know to run an application automatically on shut down is by using logout hooks. save the workflow as an application and then add a logout hook to run this application. see this link on how to make logout hooks

http://www.bombich.com/mactips/loginhooks.html

I'm not too sure though how well this will work tough because I don't know at what point in the logout process the hook is executed. also, it might cancel the logout.

there is also the following workaround but it requires keeping a certain application open all the time.


again, save the workflow as an application.

then paste the following apple script into Script Editor

<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #ADD8E6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
on quit
tell application "Main HD:Applications:Safari.app" to launch
-- desired actions here
continue quit
end quit</pre>

the example above works with safari. put the path to your own application there. also put the name of your hard drive instead of Main HD in the above.

save the script as an application and check the box "stay open". add the resulting application to your login items.

Nov 23, 2008 2:39 PM in response to Øivind Idsø

Yes. Just add it to the Automator workflow with the "Run AppleScript" action and save it as an application to put in your Dock, or the sidebar in a Finder window, or the toolbar in a Finder window.

If you don't want it to be too easy, then put it in a folder first. Then put the folder either in the Dock, or the sidebar or toolbar of the Finder window so you'll have to perform two clicks.

In the "Run AppleScript" action, you can delete everything in the text box since you don't need to process any items, and then add this:

tell application "System Events" to shut down

Note that "shut down" is two words. You can also use the words "restart", "sleep", or "log out". There will not be a confirmation dialog, excepting when applications ask to save unsaved documents (unless sleeping).

In the future, you can find this is out again with Script Editor somewhere in the Applications folder (or use Spotlight). You'll want to open the "System Events" scripting dictionary, and it's probably already in the "Library" window (check the Window menu, or Command-Shift-L). Use the search in the "System Events" dictionary window to find "shut down", or anything else.

Be careful about testing this script since it will immediately shutdown the computer without a confirmation dialog. Perhaps have an unsaved document opened while testing, such as another Automator workflow with any action added and unsaved, or a new TextEdit document with a some random text typed in (a single letter will do).

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Possible to run Automator job before shutdown (automatically)?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.