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:
An alternative to the accepted answer which doesn't involve having to put null characters into the batch file is as follows:
@echo off
set NULL_FILE=null.txt
set DEBUG_COMMANDS=write-null.dbg
echo e 100 >%DEBUG_COMMANDS%
echo 0 >>%DEBUG_COMMANDS%
echo n %NULL_FILE% >>%DEBUG_COMMANDS%
echo rbx >>%DEBUG_COMMANDS%
echo 0 >>%DEBUG_COMMANDS%
echo rcx >>%DEBUG_COMMANDS%
echo 1 >>%DEBUG_COMMANDS%
echo w >>%DEBUG_COMMANDS%
echo q >>%DEBUG_COMMANDS%
debug < %DEBUG_COMMANDS% >nul
del %DEBUG_COMMANDS%
This is obviously more verbose and also has the downside that it won't work on Win64 machines (due to debug no longer being available in those environments).