使用Wmic命令查找前10个进程 [英] Find top 10 processes with wmic command

查看:147
本文介绍了使用Wmic命令查找前10个进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以做 wmic进程列表摘要以显示进程列表。有没有办法查看使用最多内存的前10个进程?

I know I can do 'wmic process list brief' to display a list of processes. Is there a way to view only the top 10 processes using the most memory?

推荐答案

@echo off
setlocal EnableDelayedExpansion

(for /F "skip=1 tokens=1,2" %%a in ('wmic process get name^,workingsetsize') do (
   set "size=         %%b"
   echo !size:~-10!    %%a
)) > wmic.txt
set i=0
for /F "skip=1 delims=" %%a in ('sort /R wmic.txt') do (
   echo %%a
   set /A i+=1
   if !i! equ 10 goto :end
)
:end
del wmic.txt

输出示例:

  96931840    iexplore.exe
  82161664    explorer.exe
  42319872    svchost.exe
  33656832    svchost.exe
  31469568    dwm.exe
  26943488    iexplore.exe
  25690112    SearchIndexer.exe
  18550784    svchost.exe
  17002496    taskhostex.exe
  16343040    svchost.exe

这篇关于使用Wmic命令查找前10个进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆