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?
- 345
2 Answers
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.
- 11,385
There is no direct equivalent.
As described here, calling a program in a way that doesn’t block the caller can be done with the start command, using the /b option. Dunno about output redirection in this case, though. You might have to wrap it in a batch file.
As for > /dev/null, it’s easy: >NUL. NUL is a DOS device name. The shorthand operator, however, is not available. You’ll have to go the manual way with 2>&1. Here’s some more info on that.
- 65,551