How to open a generic URL from AppleScript

applescripturl

I like to open custom URLs, such as "myscheme://a/b/c" from my AppleScript code.

This is not about opening http URLs in a web browser. This is about getting the same result as when you create an .inetloc file in the Finder and then open that file in the Finder, or invoking this code in a macOS app written in ObjC:

[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString: @"myscheme://a/b/c"]];

Best Answer

If myscheme is properly registered in the Launch Services Database to open a particular application, then you can use the open location command, which: "Opens a URL with the appropriate program."

Use as in the following examples:

set theURL to "myscheme://a/b/c"

open location theURL

Or directly:

open location "myscheme://a/b/c"

Have a look at the AppleScript Language Guide and more specifically, the open location command.