views:

10949

answers:

12

I would like a batch file to launch two separate programs then have the command line window close. Actually, to clarify, I am launching Internet Explorer with two different URLs.

So far I have something like this:

start "~\iexplore.exe" "url1"
start "~\iexplore.exe" "url2"

What I get is one instance of Internet Explorer with only the second URL loaded. Seems the second is replacing the second. I seem to remember a syntax where I would load a new command line window and pass the command to execute on load, but can't find the reference.

As a second part of the question: what is a good reference URL to keep for the times you need to write a quick batch file?

Edit: I have marked an answer, because it does work. I now have two windows open, one for each URL. (thanks!) The funny thing is that without the /d approach using my original syntax I get different results based on whether I have a pre-existing Internet Explorer instance open.

  • If I do I get two new tabs added for my two URLs (sweet!)
  • If not I get only one final tab for the second URL I passed in.
A: 

There is a setting in the IE options that controls whether it should open new links in an existing window or in a new window. I'm not sure if you can control it from the command line but maybe changing this option would be enough for you.

In IE7 it looks like the option is "Reuse windows for launching shortcuts (when tabbed browsing is disabled)".

Daniel Plaisted
+7  A: 

Try this in your batch file:

@echo off
start /d "C:\Program Files\Internet Explorer" IEXPLORE.EXE www.google.com
start /d "C:\Program Files\Internet Explorer" IEXPLORE.EXE www.yahoo.com
Rodger Cooley
A: 

I just tried this and Rodger Cooley's "start /d" option worked for launching multiple tabs in a single window from the batch. Thanks for posting!

A: 

I'm asking how to open many tabs in Internet Explorer via a batch file.

A: 

Thanks for the tip Rodger.

For me it worked as below:

@echo off

start /d IEXPLORE.EXE www.google.com

start /d IEXPLORE.EXE www.yahoo.com

With the settings in Internet Explorer 8:

  • always open popups in a new tab
  • a new tab in the current window

[email protected]

A: 

This worked for me >

start /d IEXPLORE.EXE www.google.com start /d IEXPLORE.EXE www.yahoo.com

But for some reason opened them up in Firefox instead?!?

I tried this but it merely opened up sites in two different windows :( > start /d "C:\Program Files\Internet Explorer" IEXPLORE.EXE www.google.com start /d "C:\Program Files\Internet Explorer" IEXPLORE.EXE www.yahoo.com

Sam M
See `help start` in cmd.exe : the parameter to the `/d` argument is the *path of the starting directory* -- that is, what to set the current directory to before starting the command. What your first command says is "Start up www.google.com after setting the current dir to IEXPLORE.EXE". Using `start` with just a URL launches whatever you've configured as your preferred web browser; that's why it opened Firefox.
Stephen P
A: 

Do you have Firefox setup as your default browser?

Tom
A: 

Tried with IE7 did not work so what should i do?

rajatha
A: 

For me, Roger's code works fine if already there is an instance of IE. Otherwise, it just opens IE with the last URL. :-(

I use IE8. My code goes below.

@echo off
start /d iexplore.exe http://google.com
START /d iexplore.exe http://sanspace.in
START /d iexplore.exe http://stackoverflow.com

Help please.

San
A: 

Try this so you allow enough time for the first process to start.. else it will span 2 process cause the first one is not still running when you run the second one... This happens if your computer is too fast..

@echo off
start /d iexplore.exe http://google.com
PING 1.1.1.1 -n 1 -w 2000 >NUL
START /d iexplore.exe blablabla

replace blablabla with another address

Marcelo
A: 

Doesn't work if I want to launch the IE from an other application :-(((

e-Vita
A: 

Thanks Marcelo. This worked for me. I wanted to open a new IE Window and open two tabs in that so I modified the code start iexplore.exe website PING 1.1.1.1 -n 1 -w 2000 >NUL START /d iexplore.exe website

Emi