Execute system calls programmatically without any user intervention

I'm working on a macOS application which deals with the system calls, I want one of the calls to be shutdown executable. On click of a button, which is available in the application, the system should get shutdown. I'm able to achieve this, but everytime it is invoked, user is prompted with the sudo permission, which I want to avoid. There should not be any user intervention and the system must be shutdown.

No applescript please.

The user should never be prompted with the sudo permission grant and the code can be objc or swift.

Replies

Please clarify what you mean by “shutdown”. Do you want:

  • The system to behave as if the user chose Apple menu > Shut Down?

  • Or as if you ran sudo shutdown -h now from Terminal?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"