2010-11-23 35 views
1

我有一臺電腦(Mac),被授權通過iTunes播放音樂,我想禁用它。但是,我只有ssh訪問機器。有沒有可以遠程運行的applescript(例如通過終端),我可以用它來取消授權機器?蘋果電腦反iTunes授權

我知道我可以不授權我授權的所有機器,但如果可能的話,我寧願使用此解決方案。

回答

2

我沒有看到任何屬性在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 

上述方法與蘋果遠程桌面的發送Unix的效果很好功能爲好。

此外,請注意,密碼包含在此腳本中,我不建議使用 ,但需要在取消授權窗口中使用密碼。如果您將密碼放在腳本中,請確保確保該腳本安全無虞,以免沒有人看到您的Apple密碼。

+0

謝謝;很好的回答!我不知道GUI腳本功能。目前尚未開啓,但我可以讓某人爲我啓用它,然後運行此操作以執行取消授權(使用不同的密碼)。 – 2010-11-24 04:13:53

相關問題