Post by John StocktonBut it must be nicer to do it in pure Batch - how?
Are those character code numbers in hexadecimal or in decimal?
If they're in hexadecimal, it'd be easy:
set YWD= !"#$%&'()
However, if they're hexadecimal, i.e. decimal control code 20 to 29; then I
think it's not possible using pure batch, since the control code 26 is for
EOF.
At command prompt, EOF is treated as input terminator or end of input, and
any following characters are ignored. e.g. below command line displays "abc"
and doesn't cause any error due to syntax error because of the missing
command after the pipe character. Note: the `^Z` is the EOF character
emittable from the command prompt using CTRL+Z. It's not a 2-characters
literal string.
echo abc^Zxyz |
In batch file, EOF is treated as a line separator or a command line
separator. e.g. below code displays "abc" and "xyz" in separate lines.
echo abc^Zecho xyz
Post by John StocktonI can set an environment variable YWD to characters 20-29 of a one-line
file, ending CRLF, using an ancient utility COLS, written by me.
If your COLS tool use `SetEnvironmentVariable` Windows API function, you're
only setting an environment variable which belong to that tool's process. It
won't affect the environment variable of the batch file (the CMD process)
where that tool is executed from. Meaning that, the batch file won't have
the YWD variable added. It would require `WriteProcessMemory` function to
modify environment variables of other process, and it's not a trivial thing
to achieve.