8

Here is an example of Applescript code:

do shell script "osascript -e 'tell application \"Safari\" to activate'"

do shell script "osascript -e 'tell application \"Safari\" to launch'"

Is there any difference in the behavior of these two commands?

Because, to my eyes, it appears that they accomplish exactly the same effect.

7

From the Commands Reference section of the AppleScript Language Guide:

activate Brings an application to the front, launching it if necessary.

launch Launches an application, if it is not already running, but does not send it a run command.

If an application is already running, sending it a launch command has no effect. That allows you to open an application without performing its usual startup procedures, such as opening a new window or, in the case of a script application, running its script. For example, you can use the launch command when you don’t want an application to open and close visibly. This is less useful in AppleScript 2.0, which launches applications as hidden by default (even with the run command).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .