How can I write a null ASCII character (nul) to a file with a Windows batch script?
- by Matthew Murdoch
I'm attempting to write an ASCII null character (nul) to a file from a Windows batch script without success. I initially tried using echo like this:
echo <Alt+2+5+6>
which seems like it should work (typing <Alt+2+5+6> in the command window does write a null character - or ^@ as it appears), but echo then outputs:
More?
and hangs until I press <Return>. As an alternative I tried using:
copy con tmp.txt >nul
<Alt+2+5+6><Ctrl+Z>
which does exactly what I need, but only if I type it manually in the command window. If I run it from a batch file it hangs until I press <Ctrl+Z> but even then the output file is created but remains empty.
I really want the batch file to stand alone without requiring (for example) a separate file containing a null character which can be copied when needed.