写一个bat脚本,自动执行以下任务: 1. 关闭鼠标“增强指针精度” 2. 设置虚拟内存为当前的1....

Created on: December 13, 2025

Answered using O3 by Chat01

Question

写一个bat脚本,自动执行以下任务:

  1. 关闭鼠标“增强指针精度”
  2. 设置虚拟内存为当前的1.5倍
  3. 添加电源计划(释放性能、降低延迟),要网友推荐的最新的win11的设置/配置方法
  4. 验证修改是否生效

Thought

Finalizing script details and citations

The script will enable a setting with a one-line command, and it sets an environment variable for the pagefile size. I'll mention the need to run the script as an administrator and reboot the system afterward. I’ll cite the precise lines from the sources for disabling pointer precision and working with wmic pagefileset, using correct reference IDs.

Thought for 42s

Answer

下面给出一份一键式 BAT 脚本,在 Windows 11 (管理员模式)运行即可依次完成:

  • 关闭「增强指针精度」
  • 将虚拟内存(pagefile)改为当前值的 1.5 倍
  • 复制并启用“Ultimate Performance(终极性能)”电源计划,并做几项常见的低延迟微调
  • 在末尾自动输出验证信息

保存办法:把下面代码复制到记事本,另存为 Optimize-LowLatency.bat,右键“以管理员身份运行”。执行完后重启即可完全生效。

bat
@echo off title Windows 11 低延迟优化脚本 echo 需要管理员权限,脚本将修改注册表、电源计划和虚拟内存。 pause :: ───────────────────────────────────────────── :: 1. 关闭鼠标“增强指针精度” :: 等价于把 MouseSpeed/Threshold1/Threshold2 设为 0 reg add "HKCU\Control Panel\Mouse" /v MouseSpeed /t REG_SZ /d 0 /f reg add "HKCU\Control Panel\Mouse" /v MouseThreshold1 /t REG_SZ /d 0 /f reg add "HKCU\Control Panel\Mouse" /v MouseThreshold2 /t REG_SZ /d 0 /f :: ───────────────────────────────────────────── :: 2. 将虚拟内存固定为当前值的 1.5 倍 :: 读取现有初始大小(单位 MB) for /f "skip=1 tokens=2 delims==" %%i in ('wmic pagefileset where name^="C:\\\\pagefile.sys" get InitialSize /value') do set CurrPF=%%i if "%CurrPF%"=="" ( echo 未检测到现有 pagefile 設置,使用 2048MB 作為基準 set CurrPF=2048 ) set /a NewPF=(CurrPF*3)/2 echo 當前大小 %CurrPF% MB -> 設置為 %NewPF% MB ... :: 關閉自動管理並寫入新值 wmic computersystem where name="%computername%" set AutomaticManagedPagefile=False >nul wmic pagefileset where name="C:\\\\pagefile.sys" set InitialSize=%NewPF%,MaximumSize=%NewPF% >nul :: ───────────────────────────────────────────── :: 3. 生成並啟用低延遲電源計劃 :: 3-1 複製隱藏的 Ultimate Performance 計劃 for /f "tokens=3" %%g in ('powercfg -duplicatescheme e9a42b02-d5df-448d-aa00-03f14749eb61') do set GUID=%%g :: 3-2 重命名並設為默認 powercfg -changename %GUID% "LowLatency_Optimized" powercfg -setactive %GUID% :: 3-3 常見微調(可按需增刪) :: 禁用 CPU 深度 C-state(Processor idle disable) powercfg -setacvalueindex %GUID% SUB_PROCESSOR 5d76a2ca-e8c0-402f-a133-2158492d58ad 1 :: 關閉 PCIe ASPM 省電 powercfg -setacvalueindex %GUID% SUB_PCIEXPRESS ASPM 0 :: USB 選擇性掛起 -> Disabled powercfg -setacvalueindex %GUID% SUB_USB 2a737441-1930-4402-8d77-b2bebba308a3 0 :: ───────────────────────────────────────────── :: 4. 輸出驗證結果 echo. echo ── 驗證 ── echo [鼠標加速]: reg query "HKCU\Control Panel\Mouse" | find "MouseSpeed" echo. echo [虛擬內存]: wmic pagefileset where name="C:\\\\pagefile.sys" get InitialSize,MaximumSize echo. echo [當前電源計劃]: powercfg /getactivescheme echo. echo 請重啟電腦以讓所有變更完全生效。 pause

原理与参考

步骤关键点来源
关闭增强指针精度HKEY_CURRENT_USER\Control Panel\MouseMouseSpeed=0 即可关闭(NinjaOne)
虚拟内存 1.5 × 当前值WMIC PAGEFILESET ... SET InitialSize=...,MaximumSize=... 可在批处理里修改 pagefile 大小(tutorialreference.com)
Ultimate Performance 电源计划降低微延迟该隐藏计划专为“去微延迟”设计,可用 powercfg -duplicatescheme e9a4... 一行命令显式启用(Windows Forum)

说明

  • 管理员运行:注册表、电源和 pagefile 都需要提升权限。
  • 重启要求:虚拟内存调整必须重启后才真正加载。
  • 脚本里附带了常见的 CPU C-State、PCIe ASPM、USB 选择性挂起等低延迟调节,可根据硬件情况自行注释或删减。
  • 如果系统盘不是 C:,请把 C:\\pagefile.sys 改为对应盘符后再运行。

Share this Q&A