windows and the secret /dev/null ?

This week i had something of a surprise in what was available from windows command prompt.....

Let me give you a quick bit of background.

We are doing an application migration from a very old to a very new version of a 3rd party piece of software. This migration involves running an executable which logs on to the database and does loads of dml and ddl to move up to the next version.

This utility spews out a huge amount of output to the screen that i just don't want to see and i was pretty sure this was causing an immense slow down of the whole process (total migration time 90 minutes). I contacted the vendor to see if this could be turned off and the answer was no.....

So frustrated i went away and started seeing if there was any other workaround to help with this.

A quick google revealed something that i initially thought was a mistake or some april fool.

Windows seemed to have the capability to do this style of syntax according to a microsoft technet article

command > nul 2>&1 

what!? how long has that been possible - has there been some conspiracy to hide this as its so much like unix/linux......

Anyway with this in mind i then ran my upgrade process like this

command.exe arg1 arg2 2>screenoutput.txt

So basically instead of sending stderr (2) to the screen send it all to the new textfile screenoutput.txt (the vendor seemed to be sending all the output to stderr for some reason)

A rerun of the whole process with this change now takes 36 minutes..... I've saved nearly an hour by not sending output to the screen.

A useful trick and I can't believe i didn't know it was possible before.....

Windows even has /dev/null (well its called nul in windows world) - so i could have said

command.exe arg1 arg2 2>nul

and just discarded all of the information - however in this case i did want to keep it to check the output for genuine errors.


  1. Hi Rich,
    have you ever wondered why you have a folder structure like this in Windows:

    edit hosts ...

    Must be a coincidence really.


    1. Come on, next you'll be telling me you can run oracle on windows....