Here is a simpler solution that requires a helper WSH -based script :
wscript .\runHidden.vbs bash -c "DISPLAY=:0 xmessage 'hello, world'"
To apply your own @davv startup methodology in the background, to avoid creating a new bash instance each time:
One-time action (for example, at boot time): launch a hidden bash window that remains open. This spawns 2 bash processes: the Windows bash.exe process, which owns the console window, and the WSL bash process (owned by the WSL singleton init ), which is then available to serve the background commands.
wscript .\runHidden.vbs bash
For each X Window start command : End each command with & so that it executes as a hidden instance of WSL bash asynchronously, without saving the calling instance of bash :
wscript .\runHidden.vbs bash -c "DISPLAY=:0 xmessage 'hello, world' &"
runHidden.vbs source runHidden.vbs :
' Simple command-line help. select case WScript.Arguments(0) case "-?", "/?", "-h", "--help" WScript.echo "Usage: runHidden executable [...]" & vbNewLine & vbNewLine & "Runs the specified command hidden (without a visible window)." WScript.Quit(0) end select ' Separate the arguments into the executable name ' and a single string containing all arguments. exe = WScript.Arguments(0) sep = "" for i = 1 to WScript.Arguments.Count -1 ' Enclose arguments in "..." to preserve their original partitioning. args = args & sep & """" & WScript.Arguments(i) & """" sep = " " next ' Execute the command with its window *hidden* (0) WScript.CreateObject("Shell.Application").ShellExecute exe, args, "", "open", 0
Even when starting from an application with a graphical interface (for example, through the " Run " dialog box called with Win + R ), the console does not appear in this window.
If you configured your system to run .vbs scripts with wscript.exe by default ( wscript//h:wscript/s ), you can directly call runHidden.vbs and, if you put it in your %PATH% , only the file name (root): runHidden...
Please note that the use of the script is not limited to console applications: even GUI applications can be hidden.