The reason is the WMIC results for UNICODE. While command commands exit to ANSI by default. Since the ANSI code page is smaller than UNICODE and displays differently, converting between them becomes a problem. There are several ways to solve this problem.
a. Launch a command shell using the / U switch or, if already on the command line, just type cmd / U.
Help from the Help cmd command: / U Invokes output of internal commands to a channel or file in Unicode
Thus, you will receive a UNICODE text file, and your source code does not need to be modified. However, you need to remember that always use the / U switch. Also the right way to do this:
wmic /OUTPUT:output.txt logicaldisk get name, freespace echo %date% >> output.txt
B. Converting WMIC output to ANSI (recommended. However, it depends on what you need. It just makes life easier when you decide to add to a text file. However, you will have to use 2 output files.).
wmic /OUTPUT:output.tmp logicaldisk get name, freespace TYPE output.tmp > output.txt echo %date% >> output.txt
Hope this helps someone.
source share