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 (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com