How can I write a null ASCII character (nul) to a file with a Windows batch script?

前端 未结 4 785
一整个雨季
一整个雨季 2020-12-31 12:58

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:

         


        
4条回答
  •  误落风尘
    2020-12-31 13:23

    I don't like the solution that cannot be easy copy/paste-d to text files.So few more ways:

    1) mshta (can be directly used in batch file or from command line):

    mshta vbscript:execute("CreateObject(""Scripting.FileSystemObject"").GetStandardStream(1).Write( Chr(00) ):Close")>testfile
    

    2) certutil (requires a temp file)

    echo 00>null.hex
    certutil -decodehex null.hex null.bin
    

    3) makecab just check the subroutine here - http://ss64.com/nt/syntax-genchr.html

提交回复
热议问题