2

What is the easiest way of checking the amount of RAM a specific program uses with a batch file?

I know that i can access the whole information by:

set tempfile=%temp%\temp.file
tasklist >%tempfile%

And then get a list like:

Abbildname                     PID Sitzungsname       Sitz.-Nr. Speichernutzung
========================= ======== ================ =========== ===============
System Idle Process              0 Services                   0             4 K
System                           4 Services                   0            32 K
smss.exe                       404 Services                   0           504 K
csrss.exe                      512 Services                   0         2.256 K

But how can I extract for example the amount of RAM (here "Speichernutzung") the process csrss.exe uses? Ideally with built in functions of Windows.

2

Try

wmic process where name='firefox.exe' get WorkingSetSize

Source

enter image description here

To store as a variable try (use %% if running from a bat file, or single % if running from command prompt)

for /f %a in ('wmic process where "Name='outlook.exe'" get WorkingSetSize^|findstr [0-9]') do set "var=%a"

enter image description here

  • That works like a charm. Now I just have to extract this value as a variable, so I can do a check (smaller as XX). How can I achieve that? – Heikkisorsa Sep 27 '16 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.