Disable iTunes using a script ?

There's a much despised bug in OS X wherein iTunes unexpectedly opens and in some cases, starts playing music, a podcast, or whatever the user was listening to last. see Turning off Bluetooth speaker, triggers iTunes App to open The bug can be triggered in a number of different ways but it's not the bug itself that I'm asking about today; It's an implementation of the recommended solution.

It turns out that the only way to eliminate the bug is to completely disable iTunes. The well-documented steps for doing so are:

Go to Applications folder >> highlight iTunes app shortcut >> select 'Show Package Contents' from context menu >> Contents >> Mac OS; from within this directory, rename 'iTunes' to 'iTunes-disabled' and rename 'iTunesHelper' to 'iTunesHelper-disabled'

The solution works perfectly. It's a shame to disable iTunes completely but getting some relief from iTunes randomly starting up and interfering with my workflow far outweighs any benefit that iTunes provides so I just leave it disabled and use other options for audio/video playback.

The thing is though, these days I occasionally need iTunes to stream downloaded TV shows to my AppleTV box. And each time I do, I have to undo the steps described above in order to reenable iTunes. Which leads me to my question:

Is there some way to automate the process of disabling/enabling iTunes using the method described? Like maybe some sort of script or something? Ideally, I'd have a couple of shortcuts on my desktop which when double-clicked, would disable or enable the product by renaming the relevant files. Any ideas?

iMac, Mac OS X (10.7)

Posted on Dec 30, 2015 7:46 AM

Reply
5 replies

Dec 30, 2015 8:47 AM in response to Lester GrimeNose

Yes, it is pretty easy to create two scripts, one to "activate" and one to "deactivate" iTunes, but before discussing that, what bug is that you are talkning about? I had never heard of it. Looking at the thread you linked to, this seems to be, if anything, an issue with some device drivers, not the OS.

Can you describe the circumstances that cause the issue to occur for you, including what specific external device is involved, if any?


If you still want the scripts, let me know and I will post back.

Dec 30, 2015 9:10 AM in response to Luis Sequeira1

Honestly, yeah, my desire is to just have the scripts.


One of the mistakes I made when creating this post, which I also duped to StackExchange, was to mention that I'm affected by a bug that causes iTunes to spontaneously open. That always seems to derail the discussion away from the resolution back to the details of this old bug.


But for the sake of completeness...You'll see that lots of users have been affected by this bug over the years. iTunes just spontaneously opens for no obvious reason. Although Apple never fixed the bug, people have identified various triggers that cause it to manifest. The trigger in my *particular* case is a Bluetooth device going offline. In my case it's a Bose wireless speaker but the device in question can vary from person to person. When the speaker turns off, iTunes spontaneously opens and in some cases starts playing. The obvious solution would be to simply not turn the speaker off during the day -- but unfortunately this particular device turns itself off after a certain amount of time of inactivity, even if it's plugged into a power source. This automatic shutdown behavior is a design flaw in the device, in my opinion. Apple can't do anything about that. But the OS's response to a disconnected Bluetooth device, which is to needlessly open iTunes and start playing a song, is just a bug -- plain and simple. The problem has been around for many years and Apple has shown no interest in correcting it.


People far smarter than I have tried and failed to find workarounds for the bug. The only reliable solution is to disable iTunes. The quickest and most effective way to disable iTunes is via the steps outlined in my post -- thus the needs for some disable/enablement scripts to make the process less tedious.

Dec 30, 2015 11:05 AM in response to Lester GrimeNose

Here are two little scripts to deactivate and reactivate iTunes and iTunes Helper.


Open AppleScript Editor.


In one script, type or paste the following two lines (these are TWO lines, not three or more; a long line may wrap down but it is just one line).

Save it as a script or as an application somewhere convenient and call, for example, "Disable iTunes".


do shell script "mv /Applications/iTunes.app/Contents/MacOS/iTunes /Applications/iTunes.app/Contents/MacOS/iTunes-disabled" with administrator privileges

do shell script "mv /Applications/iTunes.app/Contents/MacOS/iTunesHelper.app/Contents/MacOS/iTunesH elper /Applications/iTunes.app/Contents/MacOS/iTunesHelper.app/Contents/MacOS/iTunesH elper-disabled" with administrator privileges




Similarly, use the following two lines to create a script or application, name it, for example. "Enable iTunes":


do shell script "mv /Applications/iTunes.app/Contents/MacOS/iTunes-disabled /Applications/iTunes.app/Contents/MacOS/iTunes" with administrator privileges

do shell script "mv /Applications/iTunes.app/Contents/MacOS/iTunesHelper.app/Contents/MacOS/iTunesH elper-disabled /Applications/iTunes.app/Contents/MacOS/iTunesHelper.app/Contents/MacOS/iTunesH elper" with administrator privileges

Dec 30, 2015 12:18 PM in response to Luis Sequeira1

Thanks, man! This is great information.


I'm not too familiar with scripts but when I copied your contents into two .command files (iTunes-enable.command and iTunes-disable.command) and tried to execute it, I got some syntax errors. There were a couple of errors in the path so I tried reformatting as follows:


for disabling:


mv /Applications/iTunes.app/Contents/MacOS/iTunes /Applications/iTunes.app/Contents/MacOS/iTunes-disabled

mv /Applications/iTunes.app/Contents/MacOS/iTunesHelper.app /Applications/iTunes.app/Contents/MacOS/iTunesHelper-disabled.app


That almost worked but generated 'Permission Denied' errors. I tried adding the word 'sudo' in front of each line. I have no idea what that command does but I know you Unix guys always seem to type it at the beginning of lines. 🙂 So I revised it to:


sudo mv /Applications/iTunes.app/Contents/MacOS/iTunes /Applications/iTunes.app/Contents/MacOS/iTunes-disabled

sudo mv /Applications/iTunes.app/Contents/MacOS/iTunesHelper.app /Applications/iTunes.app/Contents/MacOS/iTunesHelper-disabled.app


That worked. It prompts for a password though. It would be nice to nix that prompt but it's not a deal-breaker. Anyway, thanks so much for the help! Not sure if you're a Bitcoin user but if you give me a Bitcoin address, I'd be happy to send you $50 for your time -- just to say thanks.


Best,


Lester

Dec 31, 2015 7:44 AM in response to Lester GrimeNose

The syntax I gave you was for AppleScript (hence my mention of AppleScript Editor); for the record, "with administrator privileges" is the AppleScript way of requesting the sudo command. Since you are messing with system-installed applications, requesting your admin password is a good thing.



Anyway, I am glad you got it working. No bitcoins necessary :-)

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Disable iTunes using a script ?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.