參考 ...
rem 如果wmi服務(服務名為Winmgmt)壞掉了,需要到system32\webm目錄下執行如下註釋的命令 rem for %i in (*.dll) do RegSvr32 -s %i rem Regsvr32 -s scrcons.exe rem Regsvr32 -s unsecapp.exe rem Regsvr32 -s wbemtest.exe rem Regsvr32 -s WinMgmt.exe rem Regsvr32 -s WmiApSrv.exe rem Regsvr32 -s WmiPrvSE.exe @echo off @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 >nul del %~dp0temp.vbs @echo CPU占用率: type log.tmp pause del %~dp0log.tmp