macos - 关闭mac的脚本

我正在尝试自动关闭我的 Mac,我已经尝试了节能器中的计划关机,我想 sleep ,但这些似乎不起作用。 VLC 播放器 runnign 似乎可以防止关机。我想我需要一个脚本来强制关闭 mac,而不管运行的各种程序可能会向屏幕抛出什么错误。

谢谢

好的,

这是我用来关闭 mac 的 applescript 代码。我已将其添加为每晚运行的 iCal 事件。

tell application "System Events" to set the visible of every process to true

set white_list to {"Finder"}

try
    tell application "Finder"
        set process_list to the name of every process whose visible is true
    end tell
    repeat with i from 1 to (number of items in process_list)
        set this_process to item i of the process_list
        if this_process is not in white_list then
            do shell script "killall \"" & this_process & "\""
        end if
    end repeat
on error
    tell the current application to display dialog "An error has occurred!" & return & "This script will now quit" buttons {"Quit"} default button 1 with icon 0
end try



tell application "System Events"
    shut down
end tell

最佳答案

你能试试一个简单的 applescript,它是这样的......

tell application "System Events"
shut down
end tell

看看它是否有效,然后你可以让它在特定时间通过 Automator 运行,等等。

https://stackoverflow.com/questions/5565659/

相关文章:

PHP - 将 time() 调整为可被 5 整除

c - 如何在 Linux 中找到不同的内存段起始位置及其大小

math - 两次旋转之间的误差?

haskell - 将 Haskell IO 列表转换为列表类型

scheme - Racket 中的gensym

php - 使用正则表达式阻止某些电子邮件提供商

.net - 如何在 Visual Studio 2010 的解决方案资源管理器中突出显示当前打开的

mongodb - 我可以在 MongoDB 中存储关系数据库结构吗

cuda - OpenCL (Cuda) 中的逐元素运算

asp.net - 在 asp 的 gridview 中使用 eval 获取 this 对象