I know I have already answered a similar question (Running Batch File in background when windows boots up), but this time I need to launch a batch:
The first batch is executed in a console window. However, I do not want the second batch (launched by the first in a asynchronous way) to also display a console window.
I have come up with a VBScript script which does just that, and I put the script as an answer for others to refer to, but if you have other ideas/solutions, feel free to contribute.
Note: The console window of Windows command processor is named not really correct DOS window by many people.
Thank you all for the answers. From what I understand, if I need to asynchronously call a script to run in an invisible mode:
start /b
is enough.Here is a possible solution:
From your first script, call your second script with the following line:
wscript.exe invis.vbs run.bat %*
Actually, you are calling a vbs script with:
%*
)Then, invis.vbs will call your script with the Windows Script Host Run() method, which takes:
Here is invis.vbs:
set args = WScript.Arguments
num = args.Count
if num = 0 then
WScript.Echo "Usage: [CScript | WScript] invis.vbs aScript.bat <some script arguments>"
WScript.Quit 1
end if
sargs = ""
if num > 1 then
sargs = " "
for k = 1 to num - 1
anArg = args.Item(k)
sargs = sargs & anArg & " "
next
end if
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run """" & WScript.Arguments(0) & """" & sargs, 0, False