Cocoa app system restart

前端 未结 3 925
无人及你
无人及你 2021-01-23 18:12

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 coul

相关标签:
3条回答
  • 2021-01-23 18:40

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

    0 讨论(0)
  • 2021-01-23 18:43

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

    0 讨论(0)
  • 2021-01-23 18:49

    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.

    0 讨论(0)
提交回复
热议问题