写一个bat脚本,自动执行以下任务: 1. 关闭鼠标“增强指针精度” 2. 设置虚拟内存为当前实际物...
Created on: December 13, 2025
Answered using GPT-5.2 Thinking by Chat01
Created on: December 13, 2025
Answered using GPT-5.2 Thinking by Chat01
写一个bat脚本,自动执行以下任务:
写一个bat脚本,自动执行以下任务:
下面是一份 Windows 11 用的一键优化 .bat(会自动提权管理员),按你要求做:
注意:虚拟内存设置在“下次开机”创建/调整生效(WMI 也说明页文件参数在系统启动时用于创建)(Microsoft Learn)
Win11_Gaming_Tweak.bat,右键“以管理员身份运行”)bat@echo off setlocal EnableExtensions EnableDelayedExpansion :: ========================= :: Self-elevate to Admin :: ========================= net session >nul 2>&1 if %errorlevel% neq 0 ( echo [*] 需要管理员权限,正在自动提权... powershell -NoProfile -ExecutionPolicy Bypass -Command "Start-Process -FilePath '%~f0' -Verb RunAs" exit /b ) echo ================================================== echo Win11 Gaming Tweak (Mouse + Pagefile + Power Plan) echo ================================================== echo. :: ========================= :: 1) Disable Enhance Pointer Precision :: ========================= echo [1/4] 关闭鼠标“增强指针精度”(指针加速)... reg add "HKCU\Control Panel\Mouse" /v MouseSpeed /t REG_SZ /d 0 /f >nul reg add "HKCU\Control Panel\Mouse" /v MouseThreshold1 /t REG_SZ /d 0 /f >nul reg add "HKCU\Control Panel\Mouse" /v MouseThreshold2 /t REG_SZ /d 0 /f >nul :: 刷新用户参数(不保证所有机器立即生效,但无害) rundll32.exe user32.dll,UpdatePerUserSystemParameters 1,True >nul 2>&1 echo OK :: 参考:EPP 对应的注册表就是这三个值([tenforums.com](https://www.tenforums.com/tutorials/101691-turn-off-enhance-pointer-precision-windows.html?utm_source=chatgpt.com)) echo. :: ========================= :: 2) Set Pagefile = 1.5x RAM :: ========================= echo [2/4] 设置虚拟内存(pagefile) = 物理内存 * 1.5 (初始=最大)... set "TMPPS1=%temp%\_set_pagefile_15x.ps1" > "%TMPPS1%" ( echo $ErrorActionPreference = 'Stop' echo $ramBytes = (Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory echo $sizeMB = [math]::Round(($ramBytes/1MB) * 1.5) echo $drive = $env:SystemDrive echo $name = "$drive\pagefile.sys" echo echo # Disable auto management echo $cs = Get-CimInstance Win32_ComputerSystem echo $cs.AutomaticManagedPagefile = $false echo Set-CimInstance -InputObject $cs ^| Out-Null echo echo # Create/Update pagefile setting echo $filterName = $name -replace '\\','\\\\' echo $pfs = Get-CimInstance Win32_PageFileSetting -Filter ("Name='" + $filterName + "'") -ErrorAction SilentlyContinue echo if (-not $pfs) ^{ echo New-CimInstance -ClassName Win32_PageFileSetting -Property @{Name=$name; InitialSize=$sizeMB; MaximumSize=$sizeMB} ^| Out-Null echo ^} else ^{ echo $pfs.InitialSize = $sizeMB echo $pfs.MaximumSize = $sizeMB echo Set-CimInstance -InputObject $pfs ^| Out-Null echo ^} echo echo "PAGEFILE_MB=$sizeMB" ) for /f "tokens=2 delims==" %%A in ('powershell -NoProfile -ExecutionPolicy Bypass -File "%TMPPS1%"') do set "PFMB=%%A" del /f /q "%TMPPS1%" >nul 2>&1 if defined PFMB ( echo OK 设为 %PFMB% MB(提示:通常需要重启后完全生效) ) else ( echo [!] 设置失败:未能计算/写入 pagefile ) echo. :: ========================= :: 3) Add + activate "Ultimate Performance" power plan and tweak :: ========================= echo [3/4] 添加并启用 Win11 游戏电源计划(Ultimate Performance/卓越性能)... :: 通过 PowerShell 抓取 powercfg 输出中的 GUID(避免中文系统解析失败) for /f %%G in ('powershell -NoProfile -Command ^ "$o = powercfg -duplicatescheme e9a42b02-d5df-448d-aa00-03f14749eb61; ^ ($o | Select-String -Pattern ''[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}'' ).Matches.Value | Select-Object -First 1"') do set "UPGUID=%%G" if not defined UPGUID ( echo [!] 无法创建计划(可能已存在/系统限制),尝试继续用当前计划做低延迟参数... ) else ( powercfg -setactive %UPGUID% >nul 2>&1 echo OK 已启用方案 GUID=%UPGUID% ) :: 低延迟/性能向常见调整(AC=插电时) :: PCIe Link State Power Management = Off (0)([Microsoft Learn](https://learn.microsoft.com/en-us/answers/questions/1332551/how-to-modify-link-state-power-management-to-be-mo?utm_source=chatgpt.com)) powercfg /setacvalueindex SCHEME_CURRENT 501a4d13-42af-4429-9fd1-a8218c268e20 ee12f906-d277-404b-b6da-e5fa1a576df5 0 >nul 2>&1 :: USB Selective Suspend = Disabled (0)(MS 文档示例用 0 来关闭该项)([Microsoft Learn](https://learn.microsoft.com/en-us/troubleshoot/microsoftteams/teams-rooms-and-devices/usb-selective-suspend-status-unhealthy?utm_source=chatgpt.com)) powercfg /setacvalueindex SCHEME_CURRENT 2a737441-1930-4402-8d77-b2bebba308a3 48e6b7a6-50f5-4782-a5d4-53bb8f07e226 0 >nul 2>&1 :: Hard disk idle = Never (0) powercfg /setacvalueindex SCHEME_CURRENT 0012ee47-9041-4b5d-9b77-535fba8b1442 6738e2c4-e8a5-4a42-b16a-e040e769756e 0 >nul 2>&1 :: CPU min/max = 100% powercfg /setacvalueindex SCHEME_CURRENT 54533251-82be-4824-96c1-47b60b740d00 893dee8e-2bef-41e0-89c6-b55d0929964c 100 >nul 2>&1 powercfg /setacvalueindex SCHEME_CURRENT 54533251-82be-4824-96c1-47b60b740d00 bc5038f7-23e0-4960-96da-33abaf5935ec 100 >nul 2>&1 powercfg -setactive SCHEME_CURRENT >nul 2>&1 echo OK 已写入低延迟参数(插电) echo. :: ========================= :: 4) Verify :: ========================= echo [4/4] 验证修改是否生效(输出查询结果)... echo. echo ---- Mouse (EPP) Registry ---- reg query "HKCU\Control Panel\Mouse" /v MouseSpeed reg query "HKCU\Control Panel\Mouse" /v MouseThreshold1 reg query "HKCU\Control Panel\Mouse" /v MouseThreshold2 echo. echo ---- Pagefile (WMI) ---- powershell -NoProfile -Command "Get-CimInstance Win32_ComputerSystem | Select-Object AutomaticManagedPagefile | Format-List" powershell -NoProfile -Command "Get-CimInstance Win32_PageFileSetting | Select-Object Name,InitialSize,MaximumSize | Format-Table -AutoSize" echo. echo ---- Active Power Plan ---- powercfg /getactivescheme echo. echo ---- Power Tweaks (AC) Quick Query ---- echo [PCIe ASPM] powercfg /query SCHEME_CURRENT 501a4d13-42af-4429-9fd1-a8218c268e20 ee12f906-d277-404b-b6da-e5fa1a576df5 echo [USB Selective Suspend] powercfg /query SCHEME_CURRENT 2a737441-1930-4402-8d77-b2bebba308a3 48e6b7a6-50f5-4782-a5d4-53bb8f07e226 echo. echo ========================= echo 完成。建议重启一次,让 pagefile 设置完全生效。 echo ========================= pause
HKCU\Control Panel\Mouse 的 MouseSpeed/MouseThreshold1/MouseThreshold2 为 0。(tenforums.com)powercfg -duplicatescheme e9a42b02-d5df-448d-aa00-03f14749eb61。(Pureinfotech)如果你希望脚本把“只在插电时启用这些激进设置、用电池时自动回到平衡”,我也可以给你加上 DC(电池)分支。