Nathan
Nathan

Reputation: 1525

Launching a website via the Windows commandline

I have a program launching a website via the following command.

cmd "start /max http://url.com"

When launching a website via this method, it uses the default browser with its default settings for opening a new window. For example, Firefox and Internet Explorer will open the window inside the tab of an existing window if they are set to do so. I have reports of Internet Explorer 6 replacing the content of a current opened window with the content of url.com.

I've tested this and sure enough, when Internet Explorer 6 is set as the default browser and with a current webpage opened, the above will replace the content of the opened window with url.com rather than opening a fresh window.

Upon running some tests, I see the command listed here:

cmd "start /max iexplore.exe http://url.com"

will consistently open a new window (with Internet Explorer of course) regardless of an existing window being present or not.

Am I missing a silly setting in Internet Explorer 6, or is there a way to duplicate the "always open a new window" functionality exhibited by calling iexplore.exe directly, but with calling the user default browser instead?

Launching a website via the Windows commandline

Upvotes: 85

Views: 299338

Answers (9)

Russell Abraham
Russell Abraham

Reputation: 21

OK, the Windows 10 batch file is done, and it works just like I had hoped.

First press the Windows key and R. Type mmc and Enter. In File, Add SnapIn → go to a specific website and add it to the list. Press OK in the tab, and on the left side console root menu, double-click your site.

Once it opens, add it to favourites. That should place it in C:\Users\user\AppData\Roaming\Microsoft\StartMenu\Programs\Windows Administrative Tools.

I made a shortcut of this to a folder on the desktop. Right-click the Shortcut and view the properties. In the Shortcut tab of the Properties, click Advanced and check the Run as Administrator. The Start in Location is also on the Shortcuts Tab. You can add that to your batch file if you need. The batch file I made is as follows:

@echo off
title Manage SiteEnviro
color 0a
:Clock
cls
echo Date:%date% Time:%time%
pause
cls
c:\WINDOWS\System32\netstat
c:\WINDOWS\System32\netstat -an
goto Greeting

:Greeting
cls
echo Open ShellSite
pause
cls
goto Manage SiteEnviro

:Manage SiteEnviro
"C:\Users\user\AppData\Roaming\Microsoft\Start Menu\Programs\Administrative Tools\YourCustomSavedMMC.msc"

You need to make a shortcut when you save this as a .bat file and in the PropertiesShortcutsAdvanced, enable administrator access. You can also set a keyboard shortcut there and change the icon if you like.

I probably did not need :Clock. The netstat commands can change to setting a hosted network or anything you want, including nothing. It can cascade websites in one mmc console and have more than one favourite added into the batch file.

Upvotes: 1

VitaminYes
VitaminYes

Reputation: 151

Working from VaLo's answer:

cd %directory to browser%
%Browser's name to the main executable (firefox, chrome, opera, etc.)% https://www.google.com

start https://www.google.com doesn't seem to work (at least in my environment)

Upvotes: 2

VaLo
VaLo

Reputation: 29

You can start web pages using the command line in any browser typing this command:

cd %your chrome directory%
start /max http://google.com

Save it as a .bat file and run it :)

Upvotes: 2

Franci Penov
Franci Penov

Reputation: 76021

Internet Explorer has a setting, located in ToolsInternet optionsAdvancedBrowsing, called Reuse windows for launching shortcuts, which is checked by default.

For Internet Explorer versions that support tabbed browsing, this option is relevant only when tab browsing is turned off (in fact, Internet Explorer 9 Beta explicitly mentions this). However, since Internet Explorer 6 does not have tabbed browsing, this option does affect opening URLs through the shell (as in your example).

Upvotes: 6

Jay Wick
Jay Wick

Reputation: 13797

Windows

explorer "https://google.com"

Which will launch your default browser and navigate to that site.

As @RiverHeart pointed out if your URL has special characters like ? you can escape the URL like so in Windows 10+

explorer "`"https://www.google.com/search?q=hello+there"`"

MacOS

open "https://google.com"

Upvotes: 186

Tahcin Ul Karim Mycin
Tahcin Ul Karim Mycin

Reputation: 121

This worked for me:

explorer <YOUR URL>

For example:

explorer "https://www.google.com/"

This will open https://www.google.com/ in your default browser.

Upvotes: 11

Vadorequest
Vadorequest

Reputation: 18079

Using a CLI, the easiest way (cross-platform) I've found is to use the NPM package https://github.com/sindresorhus/open-cli

npm install --global open-cli

Installing it globally allows running something like open-cli https://unlyed.github.io/next-right-now/.

You can also install it locally (e.g: in a project) and run npx open-cli https://unlyed.github.io/next-right-now/

Or, using a NPM script (which is how I actually use it): "doc:online": "open-cli https://unlyed.github.io/next-right-now/",

Running yarn doc:online will open the webpage, and this works on any platform (windows, mac, linux).

Upvotes: 0

kjv
kjv

Reputation: 1097

To open a URL with the default browser, you can execute:

rundll32 url.dll,FileProtocolHandler https://www.google.com

I had issues with URL parameters with the other solutions. However, this one seemed to work correctly.

Upvotes: 45

prime
prime

Reputation: 15594

start chrome https://www.google.com/ or start firefox https://www.google.com/

Upvotes: 37

Related Questions