0

So my Batch file command goes as follows:

@ECHO OFF
SET link1=google.com
SET link2=google.com
SET link3=google.com
START /MAX vivaldi.exe %link1% %link2% %link3%

When I double click my .BAT file, it only opens a new vivaldi window if there isn't one currently running. If I already have a vivaldi window open it will simply just open links 1-3 in new tabs on top of the tabs I already have open(and maximize the window if it is not). I was under the impression that the START command should always open the .EXE in a new window unless the /B flag is set(which it is not)?

JoezCodes
  • 157
  • 2
  • 15
Zac
  • 109
  • 1
  • 1
  • 8
  • No doubt `vivaldi` is a browser of some kind. The choice of opening a new browser instance or new tabs within the current instance is made by the browser, not by batch. In Firefox, there's a switch under Tools/Options/General/Tabs - a checkbox labelled "When you open a link in a new tab, switch to it immediately". Vivaldi? IDK. – Magoo Dec 28 '17 at 19:27
  • *I was under the impression that the START command should always open the .exe in a new window unless the /B flag is set(which it is not)?* NOPE. Try reading help carefully (`start /?`). Why would you be using the non normal way to start a program. See here for a summary of how to start programs. https://stackoverflow.com/questions/41030190/command-to-run-a-bat-file/41049135#41049135 – ACatInLove Dec 28 '17 at 20:47
  • Oh - that checkbox is the `Open new windows in a new tab instead` box, sorry. – Magoo Dec 29 '17 at 02:34
  • `/b` relates to console applications. It uses the creation flag `CREATE_NEW_PROCESS_GROUP` instead of `CREATE_NEW_CONSOLE`. So a console app will inherit the current console instead of allocating a new one. Ctrl+C is disabled since it's a background process, in which case you should also redirect stdin to NUL. Otherwise use `start /b /w` (in that order) to make CMD [w]ait. You might use this to have the shell start a console app by name via its shell "App Paths" key instead of searching `PATH`, or if you needed another `start` option such as setting the CPU affinity. – Eryk Sun Dec 29 '17 at 09:38
  • Large programs, like a browser, are almost always implemented as a singleton program. The second time you start it, it can see that it is already running and passes the arguments to the first instance. And quits. There is nothing that START can do about it, this behavior is purely implemented by the program itself. And unless the program gives you a magic command line option to suppress this behavior, nor can you. Ask at superuser.com or the Vivaldi support forum. – Hans Passant Dec 31 '17 at 13:31

1 Answers1

0

Replace your last line with:

START /MAX vivaldi.exe --user-data-dir=c:\temp %link1% %link2% %link3%

You could create a dedicated folder rather than use C:\temp, and specify the full path to that instead.

Inspiration for the use of --user-data-dir from https://superuser.com/a/457045/122072.

Jimadine
  • 998
  • 13
  • 26