开发者

Cocoa app system restart

开发者 https://www.devze.com 2023-02-21 22:18 出处:网络
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 shu开发者_开发知识库tdown to the user so the user could stop

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 shu开发者_开发知识库tdown to the user so the user could stop the restarting procedure.

Regards


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


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消