Re: Use kAERestart to Restart Computer
Re: Use kAERestart to Restart Computer
- Subject: Re: Use kAERestart to Restart Computer
- From: Nick Zitzmann <email@hidden>
- Date: Tue, 21 Jun 2011 00:21:37 -0600
On Jun 19, 2011, at 11:00 PM, Andy Boutte wrote:
> Does any body have some sample code that they can share that will restart the computer? I have looked at the code on these pages:
>
> http://applerr.com/forum/mac/3648/programmatically-put-a-mac-into-sleep.htm
> http://developer.apple.com/library/mac/#qa/qa1134/_index.html
>
> What I cant figure out is what code I should put in my IBAction to make the restart happen.
>
> -(IBAction) buttonAction: (id) sender {
>
> }
Something like this has worked for me: (warning, written in Mail, untested but should work, use at your own risk)
NSAppleScript *restartAS = [[NSAppleScript alloc] initWithSource:@"tell application \"System Events\" to restart"];
[restartAS executeAndReturnError:NULL];
[restartAS release];
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden