Q. How can a script open a URL using your default browser?

My first thought was to extract the default browser from the default text string at HKEY_CLASSES_ROOT\htmlfile\shell\open\command, using:

for /f "Tokens=3*" %%a in ('reg query HKCR\htmlfile\shell\open\command /VE^|find "REG_SZ"') do (
  set browser=%%b
)
until I realized that the Start command would open a URL using the default browser.

I have scripted OpenURL.bat to open a specified URL in your default browser.

The syntax for using OpenURL.bat is:

OpenURL URL

Where URL is the URL of the page you wish to open, like HTTP://WWW.JSIFAQ.COM or WWW.JSIFAQ.COM.

OpenURL.bat contains:

@echo off
if \{%1\}==\{\} @echo Syntax: OpenURL URL&goto :EOF
Start /MIN %1


Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish