cmd查询cpu使用率

阅读更多

引自:https://zhidao.baidu.com/usercenter?uid=ee854069236f25705e790c08

源码保存为bat文件执行即可:

@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占用率:
type log.tmp
pause(添加)

 最后一行是为了能直接在cmd下看到输出结果。O(∩_∩)O哈哈~

 

  • cpu.zip (472 Bytes)
  • 下载次数: 0

你可能感兴趣的:(cpu占用率)