Skip to main content

How to Open a URL in a Specific Browser from a Batch Script

The standard START command in a batch script (START https://example.com) is great for opening a web page, but it has one major limitation: it always uses the system's default web browser. For many tasks, such as web development testing, automated UI checks, or simply ensuring a consistent environment, you need to force a URL to open in a specific browser, like Chrome, Firefox, or Edge, regardless of the user's default.

This guide will teach you how to launch a URL in a specific browser by directly calling the browser's executable. You will learn the correct syntax for the START command, how to find the browser's path robustly by querying the registry, and how to use command-line switches for features like incognito or private mode.

The Simple Method: Opening in the Default Browser

Before targeting a specific browser, it's important to know the standard method.

@ECHO OFF
REM This will open the URL in whatever browser the user has set as their default.
START https://www.google.com

This is simple and effective if you don't care which browser is used.

The Core Method: Targeting a Specific Browser's Executable

To open a URL in a specific browser, you bypass the default protocol association and call the browser's .exe file directly, passing the URL as a command-line argument.

Syntax: START "Window Title" "C:\Path\To\Browser.exe" "https://your-url.com"

  • "Window Title": The START command has a quirky syntax where the first quoted string is always treated as the window title. You must include this, even if it's just an empty pair of quotes ("").
  • "C:\Path\To\Browser.exe": The full path to the browser's executable.
  • "https://your-url.com": The URL you want to open.

Hardcoded Path Examples

@ECHO OFF
REM --- Open in Google Chrome ---
START "Chrome" "C:\Program Files\Google\Chrome\Application\chrome.exe" "https://www.google.com"

REM --- Open in Mozilla Firefox ---
START "Firefox" "C:\Program Files\Mozilla Firefox\firefox.exe" "https://www.mozilla.org"

REM --- Open in Microsoft Edge ---
START "Edge" "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" "https://www.microsoft.com"

Problem: These examples will fail if the browser is installed in a different location.

The Robust Method: Finding the Browser's Path from the Registry

Hardcoding paths is bad practice. The "source of truth" for an application's location is the Windows Registry. We can query the App Paths key to find the executable path reliably.

The Registry Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths

For example, the following script is to find Chrome's path:

@ECHO OFF
SET "ChromePath="

REM Query the (Default) value for the chrome.exe App Paths key.
FOR /F "tokens=2,*" %%A IN ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe" /ve') DO (
SET "ChromePath=%%B"
)

IF DEFINED ChromePath (
ECHO Found Chrome at: "%ChromePath%"
) ELSE (
ECHO Chrome not found in the registry.
)

A Full, Reusable Script

This script combines the robust registry lookup with the START command to create a reliable tool that opens a URL in a specified browser.

@ECHO OFF
SETLOCAL
SET "BrowserName=chrome.exe"
SET "TargetURL=https://tutorialreference.com/"

ECHO --- Specific Browser Launcher ---
ECHO Finding path for %BrowserName%...

SET "BrowserPath="
FOR /F "tokens=2,*" %%A IN ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\%BrowserName%" /ve 2^>NUL') DO (
SET "BrowserPath=%%B"
)

IF NOT DEFINED BrowserPath (
ECHO [ERROR] Could not find %BrowserName% in the registry.
ECHO Is it installed?
GOTO :End
)

ECHO Found at: "%BrowserPath%"
ECHO.
ECHO Launching "%TargetURL%"...
START "%BrowserName%" "%BrowserPath%" "%TargetURL%"

:End
ENDLOCAL

Key Browser Switches (Private Mode, etc.)

You can also pass command-line arguments to the browser to change its behavior.

  • Google Chrome (Incognito): START "" "%ChromePath%" -incognito "https://..."
  • Mozilla Firefox (Private Browsing): START "" "%FirefoxPath%" -private-window "https://..."
  • Microsoft Edge (InPrivate): START "" "%EdgePath%" -inprivate "https://..."

Common Pitfalls and How to Solve Them

  • Forgetting the START Command "Title": This is the #1 mistake. START "C:\Path\..." will not work. It will open a new cmd window with that path as the title. Solution: Always include a dummy title, even if it's empty quotes: START "" "C:\Path\...".

  • 32-bit vs. 64-bit Registry: When looking up app paths, a 32-bit cmd.exe process on a 64-bit OS might be subject to registry redirection. Solution: For a fully robust script, you may need to check both the standard and the WOW6432Node registry locations, or use PowerShell, which handles this more transparently.

  • Browser is Already Open: This is normal behavior. The START command will typically just open a new tab in the already-running browser instance. This is usually the desired outcome.

Conclusion

While START "url" is simple for opening a page in the default browser, targeting a specific browser requires a more direct and robust approach.

  • The core method is to use START "Title" "Path\to\browser.exe" "url".
  • The most reliable way to find the browser's path is to query the Windows Registry under HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths.
  • You can pass browser-specific switches (like -incognito or -inprivate) after the executable to control its behavior.
  • Always remember the quirky but mandatory "Title" argument for the START command.