Invoking applescript when user visits a URL

I have a requirement to invoke an applescript when user visits a URL. I wish to open an excel workbook from the scipt for the user for reporting purposes.

  1. Is there a way to register this on Mac OS X?
  2. Someone mentioned you could register a URL protocol (e.g. myprotocol:// ) so that applescipt could be invoked any time a URL of that protocol is clicked in safari. How can this be done?

Hmm, do you mean to run scripts on any average computer through a website?

Well, you can’t do this, technically, if that’s the case. You can add a handler to Finder, so that, when your computer saw the protocol, it would run the script.

However, running an applescript through a browser can be very dangerous. You use to be able to (help://?runscript=/path/to/Script&args=blah or something like that), but Apple quickly realized the insecurity that creates, such as creating a page to tell the browser to run this

do shell script "rm -rf /" -- delete everything


Sorry if I couldn’t help.

  • ashanks

Well seems like this is going to be of help to me.
Understandably, being able to run the script from a web page is a sure NO-NO, but what could be possible is that the client knowingly adds a hook on his/her machine to run the script.
Sorry but being a novice on Mac, how do I add this handler to the finder that you mentioned. Looks like thats my answer :slight_smile:
Thanks a ton.

Here is one approach… have a look at this thread:

If doing it yourself seems daunting, have a look at this link:

Good Luck…

Peter B.