How can I store a NULL ASCII character (nul) in a variable with a Windows batch script? How can I store a NULL ASCII character (nul) in a variable with a Windows batch script? windows windows

How can I store a NULL ASCII character (nul) in a variable with a Windows batch script?


According to the page Environment Variables of Microsoft's MSDN Library and also to the post Setting environment variables for a specific run of a specific process, the environment block is stored in a NULL-terminated block of NULL-terminated strings -- here quickly illustrated in EBNF notation:

environment-block = { variable-definition } , null-char ;variable-definition = variable-name , '=' , variable-value , null-char ;

Due to this storage format it is not possible to store a NULL character into an environment variable. Even if one managed to get a NULL written to the environment block it could not ever be read again.