Restart Action

Ric

Joined
May 14, 2004
Messages
4,260
Reaction score
5
Xcode 2.1 normal AppleScript template...

This was just for fun, put this at the end of your workflow and your Mac will Restart once it has completed it's tasks...

...it will not "force" Restart, any unsaved documents will need to be saved, otherwise the restart will wait for user response.
 

Attachments

  • Restart_Action_Version_1.0.dmg.zip
    159.7 KB · Views: 4,158

Ric

Joined
May 14, 2004
Messages
4,260
Reaction score
5
If any one would like a "forced" Restart let me know and I'll have a go at writing one...

...sometimes you want to tell your Mac to Restart without anything stopping it !

regards

Ric
 
Joined
Nov 24, 2005
Messages
1
Reaction score
0
Were I to use this in combination with an apple script and the Mail program in order to request a restart using an emailed cell phone text message,

is there a way to automate the login procedure, too? I know this can be done from the accounts management preference pane, but I don't want it to be that universal. That is, I'd like the computer to restart and automatically log in to a particular account only when the restart request comes from the phone or (actually) the automation itself.

Is this possible?

Yours,
Richard
 

Ric

Joined
May 14, 2004
Messages
4,260
Reaction score
5
Hi Richard,

If for one minute I 'ignore' the first part of your question...

It is relatively straightforward to Automate your Mac from remote emails...

To start we can just add in a Rule into 'Mail.app' that will run an AppleScript when it gets a 'certain' email...

Go to Mail-->Preferences--> Rules


Mail001.jpg


As you can see I have put in a few sample Rules...

Now you need to click on the add rule and then name it and navigate to the AppleScript that you want it to run...it must be an AppleScript !

Mail002.jpg



Mail003.jpg


As you can see from the pics above, you need to think about what will trigger the AppleScript...you don't want a piece of Spam setting of your Shutdown--Restart etc workflows...


If you had done an elabourate workflow in Automator, then just save that as an Application, and use this as an the AppleScript, (replacing the name),

Code:
tell application "myWorkflowApp"
activate
end tell

You can replace the myWorkflowApp with any Application on your Mac.

For all of this to work, Mail App must be running, and the User logged in, set Mail to check for new mail every 5 minutes.

Then where ever you are you can send an Email with your 'code words' in to get you Mac to do something...

So on one of my Mac's at home I have a Rule set up that does this...

On receipt of the 'special email', this rule kicks in..

1) Reply to message-with the text "Instructions received Restart in Progress"

This sends me an email message telling me that the remote Mac has got the email and is running the Script.

2) Run AppleScript-this has a delay at the beginning to ensure that the 'message' above gets sent !

Code:
delay 60
tell Application "System Events"
restart
end tell

So that all works fine !

Now back to the first part of your question...

If you log out then all your Apps quit !

So one way, if there are other "Users" on that Computer, you need to enable Fast User Switching and 'switch' to another user before leaving...this will keep Mail open in your 'real user account', checking for any Mail you send, when Mail receives this email it will go off and run your Script...depending on what you want it to do it may or may work. A restart command sent to the User in the background will not restart the Mac, (this may be possible via a shell script) it would have to be sent to the 'Front most' active user, if you see what I mean !

...if you are telling your Mac to restart, then depending on what options you have set in the Accounts Pref Pane will determine who (which User) gets logged back in after the restart !

Another way would be to enable FileVault. If you have stuff on your Computer that you don't want colleagues, siblings etc to see then you can always use FileVault to protect your data. I'm not a big fan of FileVault cause it can tend to break other things...

The only other alternative is to enable SSH on your Mac, this will enable you to login to your Mac remotely and do what ever you want, as long as the Mac is turned on, it doesn't need to be logged in !

But to do this you would need a computer or a PDA that has Internet access to send the commands to the Mac, you would also need to know the IP address of that Mac !

And you would also have to allow SSH 'in' on your Firewall or/and Router...

Maybe you could create another 'User' on that machine that you would login to when leaving your home/office thus protecting your 'real' account, this 'fake' account could then be set to 'listen' for your remote commands...you could set up a free email account just for that user...

All depends on how much you 'don't want' someone else accessing your Mac ?

regards

Ric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top