Can I launch the default browser without a URL?

I looked, but could not find a way to simply launch the default browser (via macro) without also providing a URL. (I reset my default browser frequently.)
I looked around for a URL that would not throw an error, and could not find that either.

Maybe an Applescript. Cadged from the web:

tell application id DefaultBrowserID()
end tell

on DefaultBrowserID()
  do shell script "export VERSIONER_PERL_PREFER_32_BIT=yes; " & ¬
    "perl -MMac::InternetConfig -le 'print +(substr((GetICHelper \"http\"), 0,4))'"
end DefaultBrowserID


Thanks, Chris, but I ended up doing this:
Made a text file with only a space character in it.
Saved it in my home folder as "null.txt"
and then used this for the URL:


Works fine.

Something like this will work without an extant file.

open location "http://about:blank"


1 Like

Thanks for that suggestion, but in firefox and chrome, that opens


[quote=“tvalleau, post:5, topic:1118”]Thanks for that suggestion, but in firefox and chrome, that opens

Hey Tracy,

You’re running that as an AppleScript?

It should open the browser that is set as the default. It should be completely browser agnostic and operate according to the system settings for default browser.


Ah… I didn’t try as AS. I’m using the “open URL” command in KM, since that’s the only one (I can find) that operates on the default browser.

How would that look in applescript without a “tell” to a specific browswer? “Defaultbrowser” isn’t recognized. (Thing is, of course, that I’ve got it working to my satisfaction as it is now, so I’m mainly academically curious.)

I’d have to say that opening an empty text document may be more simple in most cases than constructing a specific script to open the default browser… but I’m curious.

Hey Tracy,

Exactly as written:

open location "http://about:blank"

In an Execute AppleScript Action - either text-script or script-file.

OSX knows that the address is a web address and will use the default browser to open it.

You can do the same thing in an Execute Shell Script Action like this:

open "http://about:blank"

See the man page for open in the Terminal:

man open

I think KM’s own Open A URL Action just leverages the shell’s open command.


about:blank is not treated kindly by all browsers.

So. Let’s go back to Chris Lott’s solution and update it a bit.

set defaultBrowserID to do shell script "export VERSIONER_PERL_PREFER_32_BIT=yes; " & ¬
  "perl -MMac::InternetConfig -le 'print (GetICHelper \"http\")'"
set defaultBrowserID to text 5 thru -1 of defaultBrowserID
set defaultBrowserID to path to application defaultBrowserID as text
tell application defaultBrowserID
  if not running then
  end if
end tell

Chris’ snippet relied on creator codes, and those have been deprecated in OSX - e.g. not all apps have them anymore - so I’m using the app-name instead.

The if not running - run bit is a workaround for a bug in Mavericks and perhaps Yosemite.

This AppleScript will run just a bit faster if run from a script-file rather than a text-script.


Thanks, Chris. I appreciate your time and courtesy in responding.

I see that my knowledge of “open” was deficient, as open location
"http://about:blank" does indeed open Firefox from within Script

Despite a few decades (really!) in front of a computer, there’s always
something new to learn.

Again, my thanks, and I hope this tread proves useful to others in the

Best wishes.


Chris, my apologies for pulling up such an old topic/post, but I need to get the name of the default browser. Your script runs great from SD6, but from Keyboard Maestro 8.0.4 (8.0.4) on macOS 10.11.6, I get this:

/var/folders/hb/6xgg0y8j4g530m81rd1f9mpc0000gn/T/Keyboard-Maestro-Script-6CC38660-D9A5-4115-8A81-B3702039E518:24:152: execution error: Can’t locate Mac/ in @INC (you may need to install the Mac::InternetConfig module) (@INC contains:

and then a long list of paths.


The script I ran is slightly modified:

set defaultBrowserID to do shell script "export VERSIONER_PERL_PREFER_32_BIT=yes; " & ¬
  "perl -MMac::InternetConfig -le 'print (GetICHelper \"http\")'"
set defaultBrowserID to text 5 thru -1 of defaultBrowserID
--set defaultBrowserID to path to application defaultBrowserID as text

return defaultBrowserID

since all I want is the name, not the path.


Hey Jim,

Try running this:

Execute a Shell Script.kmactions (765 B)

NOTE — the explicit path to the macOS default Perl in line 2.

If that doesn’t' work then try setting PERL5LIB to an empty string.

Don't export it to the environment — just set it anywhere before line 2.


You might also ask Shane if this can be done easily (and more quickly) with AppleScriptObjC.


Thanks, Chris. That worked without having to set the PER5LIB.

Hey Folks,

A little Mac consulting firm called HamSoft has created several useful Unix command-line executables.

Amongst them is DefaultApplication, which returns the default application used for a given file extension or URL-type.

$> stands for the command-line prompt.

By URL scheme:

$> DefaultApplication -url http:

By file extension:

$> DefaultApplication -ext txt

By feeding it a path to an actual file:

$> DefaultApplication -path ~/Downloads/

This critter is very, very fast compared to the only alternative method I’m currently aware of. (The Perl script above.)


1 Like

Thanks, Chris. It is always good to have fast options.

For my immediate purposes, compatibility with end user systems is more important than speed. So, I need to stick with the Perl solution for now. It seems fast enough. It runs in 0.08 sec on my iMac-27 Late 2015. :+1:

Even on the first run?

On my system it takes over 3 seconds to run the first time…

Subsequent runs are fast, but there’s a time-out of some kind where first-run behavior is reinitiated.


Yep. I even created a new macro and:

  • Ran it
  • Restarted the KM Engine, and ran it

Same results:

Perl Script by @ccstone

/usr/bin/perl -MMac::InternetConfig -le 'print (GetICHelper "http")' \
| sed -E 's!^.{4}!!'
1 Like