|
|
@echo off
rem 查询物理总内存:MB
set memphysical=0
rem for /f "tokens=1" %%i in ( 'wmic memorychip GET Capacity' ) do (
for /f "tokens=1" %%i in ( 'PowerShell "&{Get-WmiObject -Class Win32_PhysicalMemory | Select-Object Capacity, BankLabel}"' ) do (
if %%i==1073741824 set /a memphysical+=1024
if %%i==2147483648 set /a memphysical+=2048
if %%i==4294967296 set /a memphysical+=4096
if %%i==8589934592 set /a memphysical+=8192
if %%i==17179869184 set /a memphysical+=16384
if %%i==34359738368 set /a memphysical+=32768
)
rem 检查物理总内存
if %memphysical% lss 4096 (
echo 物理总内存不足4096MB, 无法使用UWF: %memphysical%MB.
pause
goto end
)
rem 计算覆盖缓存:MB
rem %thresholds% -- 计算值=物理总内存/4
rem %threshold% -- 设置值=1024*n
rem NEQ - 不等于
rem LSS - 小于
rem LEQ - 小于或等于
rem GTR - 大于
rem GEQ - 大于或等于
if %PROCESSOR_ARCHITECTURE%==x86 set /a thresholds=1024
if %PROCESSOR_ARCHITECTURE%==AMD64 set /a thresholds=memphysical/4
if %thresholds% geq 16384 set threshold=16384
if %thresholds% lss 16384 set threshold=8192
if %thresholds% lss 8192 set threshold=4096
if %thresholds% lss 4096 set threshold=2048
if %thresholds% lss 2048 set threshold=1024
rem 显示配置主界面
:start
rem 驱动器号uwf_volume/警告阈值thresholdw/严重阈值thresholdc
set uwf_volume=%SystemDrive%
set thresholdw=%threshold%
set thresholdc=%threshold%
if %thresholds% geq 8192 set /a thresholdw=%threshold%-2048
if %thresholds% geq 8192 set /a thresholdc=%threshold%-1024
cls
echo UWF配置:
echo -------------------------------------------------------------------
echo 驱动器号=%uwf_volume%
echo 物理内存=%memphysical%MB
echo 覆盖缓存=%threshold%MB 警告阈值=%thresholdw%MB 严重阈值=%thresholdc%MB
echo -------------------------------------------------------------------
echo 重置覆盖缓存:
echo [1]=1024MB [2]=2048MB [4]=4096MB [8]=8192MB [f]=16384MB
echo -------------------------------------------------------------------
echo [+]=为下次会话启用UWF
echo [-]=为下次会话禁用UWF
echo [s]=显示当前会话覆盖设置
echo [r]=重新启动
echo [x]=Exit
echo -------------------------------------------------------------------
echo.
rem 选项
:input
set/p option=请选择:
if %option%==+ goto filter_enable
if %option%==- goto filter_disable
if %option%==s goto overlay_get_config
if %option%==S goto overlay_get_config
if %option%==r goto restart
if %option%==R goto restart
if %option%==x goto end
if %option%==X goto end
if %option%==1 set threshold=1024&goto start
if %option%==2 set threshold=2048&goto start
if %option%==4 set threshold=4096&goto start
if %option%==8 set threshold=8192&goto start
if %option%==f set threshold=16384&goto start
if %option%==F set threshold=16384&goto start
goto start
rem +=启用UWF
:filter_enable
echo.
uwfmgr.exe filter enable
uwfmgr.exe volume protect %uwf_volume%
uwfmgr.exe overlay set-size %threshold%
uwfmgr.exe overlay set-criticalthreshold %thresholdc%
uwfmgr.exe overlay set-warningthreshold %thresholdw%
rem uwfmgr.exe servicing update-windows
echo.
echo.
echo UWF已启用, 在系统重新启动后生效.
echo 按任意键返回.&pause>nul&goto start
rem -=禁用UWF
:filter_disable
echo.
uwfmgr.exe volume unprotect %uwf_volume%
uwfmgr.exe filter disable
echo.
echo.
echo UWF已禁用, 在系统重新启动后生效.
echo 按任意键返回.&pause>nul&goto start
rem s/S=显示当前会话覆盖设置
:overlay_get_config
echo.
uwfmgr.exe filter get-config
uwfmgr.exe overlay get-config
rem 显示当前会话设置:uwfmgr.exe get-config
echo.
echo.
echo 显示完毕, 按任意键返回.&pause>nul&goto start
rem r/R=重新启动
:restart
shutdown /r /t 0
rem 结束
:end
|
|