远程桌面 AppleScript 示例
此脚本示例可用于对电脑组执行快速清理操作。
首先,它将锁定电脑屏幕以防止干扰。然后,它将删除客户端电脑的当前活跃桌面上留下的所有项目。最后,它将完成清倒客户端废纸篓并解锁屏幕。
【警告】此脚本示例仅供培训使用,不对此脚本是否适用于你的计算环境提供任何明示或暗示的保证。此脚本还将删除目标电脑上的项目。使用它的风险由你自己承担。
-- Start commanding the local copy of Remote Desktop tell application "Remote Desktop" -- decide which list to perform this on, -- in this case it's called "Classroom" set these_computers to computer list "Classroom" -- decide what locked screen text you want displayed set screen_message to "Please wait" as Unicode text -- make a UNIX script which executes an AppleScript on the remote computers set the UNIX_script to ¬ "osascript -e 'tell application \"Finder\" to move " & ¬ "(every item of the desktop whose class isn't disk) to the trash'" -- set the lock task parameters set lock_task to make new lock screen task with properties ¬ {name:"Lock Classroom", message:screen_message} -- perform the task execute lock_task on these_computers -- set the UNIX script parameters set clean_task to make new send unix command task with properties ¬ {name:"Clean Desktop", showing output:false, script:UNIX_script} -- perform the task execute clean_task on these_computers -- empty the Trash afterward execute (make new empty trash task) on these_computers -- unlock the screen when finished execute (make new unlock screen task) on these_computersend tell