150

I have a batch file that does a bunch of things and at the end needs to open up a web browser to a page. Is there a way to, in essence, call ShellExecute on a http to open the web page?

Windows Command Prompt

Ian Vink
  • 66,960
  • 104
  • 341
  • 555
  • 4
    When you say MS-DOS, I presume you mean Windows command prompt, not actual standalone MS-DOS? – NPE Oct 06 '14 at 20:03

6 Answers6

252

You can use the start command to do much the same thing as ShellExecute. For example

 start "" http://www.stackoverflow.com

This will launch whatever browser is the default browser, so won't necessarily launch Internet Explorer.

Ross Ridge
  • 38,414
  • 7
  • 81
  • 112
  • 1
    What if we want to open this webpage in a separate browser rather than the default one ? – Du-Lacoste Oct 21 '15 at 07:44
  • 9
    @DulithDeCozta If you want to open a webpage in a specific browser that installed on the machine you'll need to use something like: `C:\path\to\browser.exe http://www.stackoverflow.com`. You should ask your own question if you need more details. – Ross Ridge Oct 21 '15 at 17:34
  • 1
    What reason to use empty quotation marks? As I see `start http://www.stackoverflow.com` is enough to open page in default browser. – Daniil Palii Jan 10 '20 at 16:30
  • 5
    @Daniechka It's in case the URL needs double quotes. The command `start "http://www.stackoverflow.com"` won't work, but the command `start "" "http://www.stackoverflow.com"` will. See: https://stackoverflow.com/questions/27261692/how-do-i-use-quotes-in-cmd-start and https://stackoverflow.com/questions/44219435/why-does-wrapping-an-argument-to-cmds-start-in-quotes-cause-it-to-behave-differ – Ross Ridge Jan 10 '20 at 18:27
  • start "chrome" http://localhost:8080 worked for me – MindRoasterMir Oct 01 '21 at 16:26
5

1.To run from the default browser, use

start http://www.stackoverflow.com

Please make sure that the appropriate browser is set as default at Control Panel-> default program : enter image description here

2.To launch page from specific browser, one can use

start "iexplore.exe" http://www.stackoverflow.com

start "chrome.exe" http://www.stackoverflow.com

start "firefox.exe" http://www.stackoverflow.com
Tilak Patil
  • 71
  • 1
  • 7
  • The second part of your answer is wrong. The first argument to start in parentheses is not the name of the executable, but the title of the windows. See `START /?`, and verify with a non-existing executable such as `start "moonlanding.exe" http://nasa.gov`. – Lumi Apr 20 '23 at 07:25
3

Unfortunately, the best method to approach this is to use Internet Explorer as it's a browser that is guaranteed to be on Windows based machines. This will also bring compatibility of other users which might have alternative browsers such as Firefox, Chrome, Opera..etc,

start "iexplore.exe" http://www.website.com
Daryl Gill
  • 5,464
  • 9
  • 36
  • 69
  • 3
    still opens the default browser. The first quoted argument isn't the program to use, but the window title (ignored in case of a browser) – Stephan Nov 12 '20 at 11:25
2

When you use the start command to a website it will use the default browser by default but if you want to use a specific browser then use start iexplorer.exe www.website.com

Also you cannot have http:// in the url.

j_freyre
  • 4,623
  • 2
  • 30
  • 47
2

hh.exe (help pages renderer) is capable of opening some simple webpages:

hh http://www.nissan.com

This will work even if browsing is blocked through:

HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer
galoget
  • 722
  • 9
  • 15
npocmaka
  • 55,367
  • 18
  • 148
  • 187
0

start did not work for me.

I used:

firefox http://www.stackoverflow.com

or

chrome http://www.stackoverflow.com

Obviously not great for distributing it, but if you're using it for a specific machine, it should work fine.

galoget
  • 722
  • 9
  • 15
stackers
  • 2,701
  • 4
  • 34
  • 66