How to get the current CPU usage and available memory in batch file?

后端 未结 4 1314
盖世英雄少女心
盖世英雄少女心 2021-02-06 04:17

I am creating a simple script that outputs the current user logged in, CPU usage for the current system and the available memory?

I have managed to get the current user/

4条回答
  •  长发绾君心
    2021-02-06 04:37

    @echo off
    
    setlocal enabledelayedexpansion
    
    set Times=0
    
    for /f "skip=1" %%p in ('wmic cpu get loadpercentage') do (
    
    set Cpusage!Times!=%%p
    
    set /A Times=!Times! + 1
    
    )
    
    echo Percentage = %Cpusage0%
    
    pause
    

提交回复
热议问题