Windows – Equivalent of (foo &>/dev/null &) in Windows shell

command lineshellwindows

I'd like to run a particular application (let's call it foo) from the command line, but I don't want it holding up the terminal, putting any junk in the terminal from its output or error streams, and also want it to keep running even if I close said terminal. In Bash, I can do that using (foo &>/dev/null &), but I don't know how I would do that in Windows shell. Could someone please help me?

Best Answer

The way you would do this in Windows is:

start /B foo > NUL 2>&1

The start command will start a detached process, a similar effect to &. The /B option prevents start from opening a new terminal window if the program you are running is a console application (it is unnecessary for GUI applications). The > has the same meaning as in Linux, and NUL is Windows' equivalent of /dev/null. The 2>&1 at the end will redirect stderr to stdout, which will all go to NUL.

Related Question