Search code examples
batch-filenul

>nul wont hide output batch


Okay so, I'm pretty sure I'm not just being silly about this, but >nul is not hiding the entire output, and I'm curious as to why, and if there is a solution:

net stop "service here" >nul

See, if it fails, then it outputs said failure, but I want to hide ALL output period, how can I do that?


Solution

  • To redirect all output to nul, you have to use >nul 2>nul.

    Why? There are two output handles: stdout and stderr, the latter is used for error messages. 2 is just the number associate with the file handle of stderr (for stdout, this number is 1).