for /F "tokens=1-4* skip=3 delims= " %i in ('tasklist') do @echo 程序名:%i 進程ID:%j 內存:%m
流操作需要進行前置轉義字符^|
C語言的形式進行管理進程
#include<stdio.h>
int main() {
FILE * fp = _popen("for /F \"tokens=1-4* skip=4 delims= \" %i in ('tasklist') do @echo %i,%j,%m","rb");
char buf[1024] = { 0 };
while (!feof(fp)) {
fgets(buf, 1024, fp);
printf("%s", buf);
}
getchar();
return 0;
}