• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Use kAERestart to Restart Computer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Use kAERestart to Restart Computer (From: Andy Boutte <email@hidden>)

  • Prev by Date: User interface items not get touch events in custom view in iOS app
  • Next by Date: Agent that displays a window with textbox
  • Previous by thread: Use kAERestart to Restart Computer
  • Next by thread: NSSavePanel called from 64-bit NPAPI plugin
  • Index(es):
    • Date
    • Thread