none
"> NUL" in batch file no longer works.. RRS feed

  • Question

  • Want to use a simple command in a batch file:  echo y| net use z: /delete > nul

    It should delete the z: drive mapping if it exists and *not* show the results of the command to the user.  This was the case in XP and earlier.  Now when i use the command it *does* display the results:

    The network connection could not be found.

    More help is available by typing NET HELPMSG 2250.

    I've tested on Server 2008 and Windows 7. Same result.  Thoughts?



    • Edited by blinkyjesus Monday, October 24, 2011 3:39 PM
    Monday, October 24, 2011 3:10 PM

Answers

All replies

  • make sure you are running your command window as administrator
    :P Advice offered, If you need more help it is advised to seek the council and advice of paid professionals. The answer is always 42, or reboot.
    Monday, October 24, 2011 4:09 PM
  • Yes, the command window is being run as administrator.
    Monday, October 24, 2011 4:15 PM
  • Ok, i figured it out.  It should be: echo y| net use z: /delete >nul 2>nul
    • Marked as answer by blinkyjesus Monday, October 24, 2011 8:40 PM
    Monday, October 24, 2011 8:40 PM
  • I have the exact same issue, that piping to NUL is not longer working in latest Windows 10.

    Version is 10.0.18990.1

    E.g. this command throws an error "The system cannot find file" (even if I run it as admin):

    echo "abc" >nul

    Tuesday, October 8, 2019 8:55 AM