Applescript 取消计算机对 iTunes 的授权

发布于 2024-10-04 01:57:23 字数 154 浏览 1 评论 0原文

我有一台有权通过 iTunes 播放音乐的计算机 (Mac),但我想禁用它。但是,我只能通过 ssh 访问该机器。是否有一个可以远程运行(例如通过终端)的苹果脚本,我可以用它来取消对机器的授权?

我知道我可以取消授权我已授权的所有计算机,但如果可能的话,我更愿意使用此解决方案。

I have a computer (Mac) that is authorized to play music through iTunes which I want to disable. But, I only have ssh access to the machine. Is there an applescript I can run remotely (eg via the terminal) that I can use to de-authorize the machine?

I know that I can unauthorize all the machines I have authorized, but I would prefer to use this solution if it is possible.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

誰ツ都不明白 2024-10-11 01:57:23

我在 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 脚本中,然后将 HEREDOC 方法与 osascript 结合使用。

完整的示例如下所示:

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 Remote Desktop 的 Send Unix 功能。

另请注意,密码包含在该脚本中,我不推荐这样做
但在取消授权窗口上需要它。如果您将密码放入脚本中,请确保保护该脚本,以免任何人获得您的 Apple 密码。

I don't see any properties to authorize/deauthorize in iTunes dictionary but I just played around with GUI scripting and came up with a solution. So, the target Mac will have to have GUI Scripting enabled for the script below to work.

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

You could leave that AppleScipt on your target Mac and then just use the open command to launch it. Or you could copy the above AppleScript and paste it into a shell script and use the HEREDOC method with osascript.

The full example of this looks like this:

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

The above method works well with Apple Remote Desktop's Send Unix feature as well.

Also, note that the password is included in this script which I don't recommend
but it is needed on the deauthorize window. If you put the password in the script make sure to secure that script so no one gets ahold of your Apple password.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文