3

I want to start (launch) three programs in windows and all of them in Background i.e. No windows.

I found two ways (both using vb script to hide a bat)

Set WshShell = WScript.CreateObject("WScript.Shell") obj = WshShell.Run("H:\test.bat", 0) set WshShell = Nothing http://answers.yahoo.com/question/index?qid=20071011212557AAofTy6)

And another one here on SU:

Save this one line of text as file invisible.vbs:

CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False

To run any program or batch file invisibly, use it like this:

wscript.exe "C:\Wherever\invisible.vbs" "C:\Some Other Place\MyBatchFile.bat"

To also be able to pass-on/relay a list of arguments use only two double quotes

CreateObject("Wscript.Shell").Run "" & WScript.Arguments(0) & "", 0, False

Example: Invisible.vbs "Kill.vbs ME.exe" Source : https://superuser.com/a/62646/301368

What I want to do is to open multiple programs and all of them in background, but when I use this I have to start each one of them separately.

If I were in linux it would be easy:

#!/bin/bash
./program1 -args &
./program2 -args &
./program3 -args &

How to achieve this in windows ? (I am using the 8.1) but I'd guess it might be general enough for other versions.

(I Accept any solutions VBS / C / bat / whatever else works)

1
  • 1
    If you use the & operator from the command line (or a batch file), followed by another command (and another one if you prefer) the program won't wait for execution to finish, but instead continue to the next command. So, you could run the VBScript with your commands, and chain them together this way. stackoverflow.com/questions/8055371/…
    – JSanchez
    Feb 28, 2014 at 23:48

1 Answer 1

4

Just use the Wscript.Shell.Run method many times and make sure you don't wait on return (set 3rd arg to false).

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "program1.exe", 0, False
WshShell.Run "program2.exe", 0, False
WshShell.Run "program3.exe", 0, False

Passing args to the programs:

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run """program1.exe""" & "args", 0, False
WshShell.Run """program2.exe""" & "args", 0, False
WshShell.Run """program3.exe""" & "args", 0, False
4
  • How do I pass the args for each program ? WshShell.Run "program2.exe -args", 0, False ?
    – Mansueli
    Mar 1, 2014 at 0:32
  • @Mansueli I did it using WshShell.Run """program.exe""" & "args", 0, False like advised here, but I had a single argument and no quotes in it. Apr 26, 2023 at 15:10
  • Thanks @YinCognyto. This post is so old that I don't even remember what I was trying to do 😂. Today I would probably run this from Python instead.
    – Mansueli
    Apr 26, 2023 at 15:39
  • 1
    @Mansueli The post is ancient indeed - I only answered for future readers that might need some direction. :) As old as it is though, it helped me yesterday to give up one liners and a multiple quoting mess and just run multiple commands easily on different lines, by setting the last parameter to True. Compared to Python, this is guaranteed to work on a Windows system without requiring any installation of a dependency. Apr 27, 2023 at 16:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .