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

后端 未结 4 1308
盖世英雄少女心
盖世英雄少女心 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:46

    typeperf "\processor(_Total)\% Processor Time"  -SC 1 -y
    

    or

    C:\>logman create counter CPU_Usage3 -c "\Processor(_Total)\% Processor Time" -f csv -o %temp%\cpu.csv
    The command completed successfully.
    
    C:\>logman start CPU_Usage3
    The command completed successfully.
    
    C:\>logman stop CPU_Usage3
    The command completed successfully.
    
    C:\>type %temp%\cpu*.csv
    The system cannot find the file specified.
    

    Typeperf is not available for WindowsXP home ,but logman requires admin privileges and creates a temp file. TYPEPERF . LOGMAN . For the memory check these counters: http://ss64.com/nt/syntax-performance-counters.html

提交回复
热议问题