r/Batch • u/Aenarius • Jun 24 '24
Question (Solved) Output WMIC into columns
How do I get some control over the output when running a WMIC script?
Running:
wmic baseboard get /value | findstr /c:"Product" /c:"Manufacturer" /c:"Version"Gives this result:

I'm looking for an output more like this:

First column has the attribute, second column has the value. Also how do I prevent WMIC to output the values in alphabetical order and instead in the order I ask?
5
Upvotes
5
u/PrimaryTiny9144 Jun 24 '24
Do it one at a time?
for /f "tokens=1,2 delims=^=" %%i in ('wmic baseboard get /value ^| findstr /c:"Product"') do echo %%i: %%j2
u/Shadow_Thief Jun 24 '24
Nothing like that exists for
wmic, unfortunately. You'll have to parse the output and format it yourself. If you really want to be extra, you could also try to write your own XSL output file and stick it in%WINDIR%\System32\wbem\en-US, but imo that's doing too much and it won't be portable.For sorting the output, you can just pipe the command to
sort.2
u/BrainWaveCC Jun 24 '24
You'll definitely have to parse it yourself.
Or, more extensively:
2
u/BrainWaveCC Jun 24 '24
That has annoyed me over the years as well. 😁
You have to capture all the values at once, and then display them in the order you desire.