Automator mac run on logout4/17/2023 We could quit all the open applications using a loop, such as the one I use in the hide all apps application, but then we would need to determine logic on how to answer certain questions that could come up. However, this can be cancelled by a screen that can’t be closed or a file that needs to be saved (which is by design given that you don’t typically want to risk loosing work) or because an application is unresponsive. Once the screen comes up you could send a subsequent command to click on the Log Out button. Osascript ‘tell application “System Events” to log out’ You can then send this through the shell using osascript: Tell application “System Events” to log out You can use AppleScript, but it’s going to ask the user to log out But it’s one of those things that there’s no real framework for at this time. One way to get close is to use the options we referenced yesterday to invoke fast user switching. But these don’t log the system out and leave you at a login window without first actually rebooting a computer we might not be ready to reboot (or we might not want to reboot/shut down). ![]() You can also replace the now with a specific time and date to set the system to shut down and/or restart in the future. You can also restart a system by running the shutdown command with a -r option and the same now as before, as follows: You can force the system to shut down by running the shutdown command with the -h option specified as now as you can see here: ![]() ![]() The second is to invoke the script as part of a deployment or as a postflight script. One is to invoke the script with the screen saver to meet some form of policy that requires a log out after a certain amount of time whether the user has saved their data or not (seems a big mean, but it’s not unheard of). Why would we want to do such a thing? Most commonly there are two requests. Scripting a log out event seems like the kind of thing that would be pretty simple, and if you use the AppleScript later it does appear simple, unless you want to force the event to occur immediately.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |