Quoted from: https://zhidao.baidu.com/usercenter?uid=ee854069236f25705e790c08
Save the source code as a bat file and execute:
@echo off @del log.tmp @echo On Error Resume Next>temp.vbs @echo.>>temp.vbs @echo dim iCpuUsePercentage>>temp.vbs @echo dim objFileStream>>temp.vbs @echo dim objTextFileWriter>>temp.vbs @echo Set objProc = GetObject("winmgmts:\\.\root\cimv2:win32_processor='cpu0'")>>temp.vbs @echo iCpuUsePercentage=objProc.LoadPercentage>>temp.vbs @echo set objFileStream =CreateObject("Scripting.Filesystemobject")>>temp.vbs @echo set objTextFileWriter=objFileStream.opentextfile("log.tmp",8,True)>>temp.vbs @echo objTextFileWriter.WriteLine(iCpuUsePercentage)>>temp.vbs @echo objTextFileWriter.close>>temp.vbs start temp.vbs ping -n 3 127.0.0.1>temp.tmp @echo CPU usage: type log.tmp pause (add)
The last line is to be able to see the output directly under cmd. O(∩_∩)O haha~