...或超过25%占用率时自动结束并重启explorer进程

发布网友

我来回答

1个回答

热心网友

set "u=24"
if exists "%var% < u" goto :EOF
pause echo 到操作
taskkill explorer.exe
start explorer.exe
>nul exit /b
这几行代码根本不会运行到,你能运行?????

@echo off
TITLE RelayServer Check
::按运行一次约5秒算,10分钟约120次
for /l %%r in (1,1,120) do (
Setlocal EnableDelayedExpansion
for /f "skip=2 tokens=2 delims==" %%i in ('wmic process where "name='explorer.exe'" get KernelModeTime^,UserModeTime /value') do (
set "x=!x! %%i"
)
call :Div !x! 5 var
if !var! geq 25 taskkill explorer.exe&start explorer.exe&goto :eof
>nul 2>nul ping /n 5 127.1
endlocal
)
exit /b
:Div dividend divisor [decimal] ||@by zj
::不支持超大数和浮点
Setlocal EnableDelayedExpansion
set "dnd=%~1"&set "dsr=%~2"&set "dec=%~3"
if %dsr% equ 0 echo 除数不能是0!&goto :EOF
set/a x=%dnd%/%dsr%
if not defined dec set "dec=8"
if %dec% equ 0 echo %x%&goto :EOF
for %%i in (%dnd:~,1% %dsr:~,1%) do if "%%i"=="-" set/a n+=1
if defined n if !n! equ 1 set "x=-0"
for /l %%i in (1 1 %dec%) do (
set/a dnd=^(a=dnd%%%dsr%^)*10,b=dnd/%dsr%
set "y=!y!!b!"
)
echo 桌面进程CPU使用率:%x%.%y:-=%
Endlocal&set %~4=%x%
goto :EOF

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com