Search code examples
windowsbatch-filecmdwsh

Windows XP or later Windows: How can I run a batch file in the background with no window displayed?


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:

  • from another batch,
  • without any console window displayed,
  • with all arguments passed to the invisible 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:

  • From a second script already in a console window, start /b is enough.
  • From Windows, without triggering a second window, my solution is still valid.

Solution

  • Do you need the second batch file to run asynchronously? Typically one batch file runs another synchronously with the call command, and the second one would share the first one's window.

    You can use start /b second.bat to launch a second batch file asynchronously from your first that shares your first one's window. If both batch files write to the console simultaneously, the output will be overlapped and probably indecipherable. Also, you'll want to put an exit command at the end of your second batch file, or you'll be within a second cmd shell once everything is done.