LooPer
LooPer

Reputation: 1479

Cocoa app system restart

Do you know any way to forcing restart an Mac OS computer from code? I tried an small applescript code without result. Applications ask for shutdown to the user so the user could stop the restarting procedure.

Regards

Upvotes: 1

Views: 1718

Answers (3)

JeremyP
JeremyP

Reputation: 86681

The official way is to send a system event to the login window process. Apple's Technical QA1134 even includes a code example.

Upvotes: 3

Tomek Wójcik
Tomek Wójcik

Reputation: 1

Try using AppleScript/ScriptingBridge from your app to tell application "Finder" to restart.

Upvotes: 0

Damien
Damien

Reputation: 2421

It's an usual thing to want to force. If the user is willing to type in their password and are an administrator of the computer; perhaps you can run

sudo reboot

from your application.

Upvotes: 1

Related Questions