I use wmic mostly as a linux-ps-equivalent in this way:
wmic process where (name="java.exe") get processId, commandline
But the output columns are ordered alphabetically so I get:
CommandLine ProcessId
java -cp ... some.Prog arg1 arg2 ... 2345
java -cp ... other.Prog arg1 arg2 ... 3456
When what I want is:
ProcessId CommandLine
2345 java -cp .... some.Prog arg1 arg2 ...
3456 java -cp .... other.Prog arg1 arg2 ...
Which would be much more readable when the commandline is long.
I’m thinking of writing a ps.bat to simplify the syntax for my use, so any batch script solutions for post-processing the wmic output are very welcome.
A simple batch file would do the job (only for your case).
It determines the start position of the second column by searching for
ProcessId, and then each line will be reordered