Search code examples
batch-filewmic

Get rid of spaces and tabs in wmic output


Using batch, trying to get output of the following command:

wmic logicaldisk get caption,description,volumename

Thus, I'm simply doing the following:

wmic logicaldisk get caption,description,volumename >>"C:\out.log"

Unfortunately, this is the output I'm getting:

output


Solution

  • The output from WMIC is unicode, your "spaces" are nulls from the two bytes unicode characters in file. Try with

    wmic logicaldisk get caption,description,volumename | find /v "" >>"C:\out.log"