Applescript: activating remote application failure

applescriptitunesremote desktop

I have an Applescript to quit my local iTunes, access a remote computer and open iTunes there:

tell application "iTunes" to quit

set remMachine to "eppc://user@0.1.2.3.4"

tell application "iTunes" of machine remMachine to activate

The following error is returned:

error "iTunes got an error: Application isn’t running." number -600

Yeah, tell me about it. You tell an application to 'open' and it fails because it isn't open.

How can I open an application on a remote machine?

Edit: I have tried changing the script to:

tell application "iTunes" to quit

set remMachine to "eppc://user@0.1.2.3.4"

tell application "Finder" of machine remMachine to do shell script "open /Applications/iTunes.app"

but the returned error is now:

error "Finder got an error: Handler does not allow remote events."
number -10016

This is actually incorrect as remote events are enabled in System Preferences.

Best Answer

Thanks to @Tetsujin for this link which provided the details for the answer.

My script now looks like this:

tell application "iTunes" to quit set remMachine to "eppc://user@0.1.2.3.4" tell application "Finder" of machine remMachine open file "Macintosh HD:Applications:iTunes" end tell

This does the following:

  1. Quits the local instance of iTunes
  2. Sets the details of the 'remmachine'
  3. Opens iTunes on the remote machine