I made a desktop application (Win and Mac) which at times may get asked by the user to do media processing that can even lasts for three hours or more, I gave the user an option to shut down computer when done.
I'm well familiar with Windows CMD but less with Mac Terminal and I want to both send shut down command and Quit my application. On Windows it's easy for me because I know how to send a delayed Shutdown request with no user interaction or approval what after it's submitted the application still have 15 seconds to quit properly.
I do not want to save a script file just to achieve that on macOS and I believe "sudo shutdown -h +2" is not an option because it requires user feedback (password)
#If TargetMacOS Then SDSC = "osascript -e 'tell application ""System Events""" + " to shut down'" #else // if it's not Mac then it must be Windows SDSC = "shutdown -s -t 15 -c ""Scheduled Shutdown starts in 15 seconds By By""" #Endif Dim sd As New Shell sd.Execute(SDSC) Quit
Of course my code works, only on Mac when I boot the system back on, my application is still open because the execution never got to the Quit part of the code.
I did try:
osascript -e 'tell app "System Events" to shut down in 15'
But it looks like "in 15" is getting ignored because I get the same result as I get without it.
Any idea would be a blessing:)