【发布时间】:2017-11-09 07:54:44
【问题描述】:
我正在尝试获取前 10 个内存消耗最多的进程,并且我正在使用 Question 中提供的代码作为答案。它工作正常,除了我不希望多个进程条目消耗不同的内存大小并且我无法对其进行排序,因为它的内存消耗不同。 代码是:
@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
)) > wmicc.txt
set i=0
for /F "skip=1 delims=" %%a in ('sort /R wmicc.txt') do (
echo %%a
set /A i+=1
if !i! equ 25 goto :end
)
:end
我可以得到如下输出:
96931840:iexplore.exe
82161664:explorer.exe
42319872:svchost.exe
31469568:dwm.exe
25690112:SearchIndexer.exe
17002496:taskhostex.exe
11007590:VCExpress.exe
8033894:avp.exe
7190528 :Skype.exe
7000416 :SkypeBrowserHost.exe
而不是现有代码的输出:
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
【问题讨论】:
标签: windows batch-file cmd wmic taskmanager