我在iTunes字典中看不到任何授权/取消授权的属性,但我只是玩了GUI脚本,想出了一个解决方案。因此,目标Mac必须启用GUI脚本才能使下面的脚本工作。
tell application "System Events"
tell process "iTunes"
click menu item "Deauthorize This Computerâ¦" of menu 1 of menu bar item "Store" of menu bar 1
delay 1
set frontmost to true
click menu 1 of menu bar item "Store" of menu bar 1
set value of text field 1 of window "Deauthorize This Computer" to "password"
click button "Deauthorize" of window "Deauthorize This Computer"
end tell
end tell
您可以将AppleScipt留在目标Mac上,然后使用open命令启动它。或者您可以复制上面的AppleScript并将其粘贴到shell脚本中,并对osascript使用HEREDOC方法。
完整的例子如下:
osascript<<END
tell application "System Events"
tell process "iTunes"
click menu item "Deauthorize This Computerâ¦" of menu 1 of menu bar item "Store" of menu bar 1
delay 1
set frontmost to true
click menu 1 of menu bar item "Store" of menu bar 1
set value of text field 1 of window "Deauthorize This Computer" to "password"
click button "Deauthorize" of window "Deauthorize This Computer"
end tell
end tell
END
上述方法同样适用于Apple远程桌面的Send Unix功能。
另外,请注意密码包含在这个脚本中,我不建议
但这是需要在解除授权窗口。如果在脚本中输入密码,请确保该脚本安全,这样就不会有人知道您的苹果密码。