- 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