theme: default themeName: "默认主题" title: "Windows Server越用越慢?这5个设置不优化,性能浪费一半"
前言
很多运维接手Windows Server后,觉得这玩意儿天生就比Linux慢半拍。其实不然,Windows Server默认装了一堆用不着的功能和服务,电源计划默认是"平衡模式",这些都在偷偷吃掉你的性能。Linux需要手动调优,Windows一样需要。今天就把Windows Server的性能优化干货整理出来,照着做,机器至少快一倍。
电源计划:性能优化的第一步
Windows Server默认电源计划是"平衡",这意味着CPU频率会根据负载动态调整。高负载时切换到高频需要时间,直接影响响应速度。
修改电源计划为高性能:# 查看当前电源计划
powercfg /list
切换到高性能模式(GUID)
powercfg /setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
或者在控制面板:电源选项 → 选择高性能。
如果你的服务器有傲腾或企业级SSD,可以忽略这个改动。但对于传统机械硬盘+虚拟机,高性能模式能明显减少延迟。
关闭不必要的服务
Windows Server自带一堆企业级服务,很多中小企业根本用不上,白白消耗资源。
建议关闭的服务:| 服务名 | 默认状态 | 建议 | 原因 |
| Windows Search | 自动 | 禁用 | 占用大量IO和CPU |
| Windows Defender | 自动 | 禁用 | 吃CPU和内存大户 |
| Remote Registry | 自动 | 禁用 | 安全风险 |
| Print Spooler | 自动 | 禁用 | 无打印机则不需要 |
| DHCP Client | 自动 | 保持 | 网络需要 |
| DNS Client | 自动 | 保持 | 网络需要 |
# 关闭Windows Search
Stop-Service "WSearch" -Force Set-Service "WSearch" -StartupType Disabled
关闭Windows Defender(企业版通常用组策略管理)
Set-MpPreference -DisableRealtimeMonitoring $true
关闭远程注册表
Stop-Service "RemoteRegistry" -Force Set-Service "RemoteRegistry" -StartupType Disabled
视觉特效:能关则关
Windows Server默认开启的视觉效果包括窗口阴影、动画、透明效果等,这些对服务器毫无意义,只会拖慢速度。
关闭视觉效果:# 调整为最佳性能
SystemPropertiesPerformance
命令行方式
New-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "MenuShowDelay" -Value "0" -PropertyType DWord -Force New-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "ForegroundLockTimeout" -Value "0" -PropertyType DWord -Force New-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "DragFullWindows" -Value "0" -PropertyType DWord -Force New-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "FontSmoothing" -Value "0" -PropertyType DWord -Force New-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "VisualFXSetting" -Value "2" -PropertyType DWord -Force New-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "UserPreferencesMask" -Value "90 24 01 80" -PropertyType Binary -Force
或者直接:右键此电脑 → 属性 → 高级系统设置 → 高级 → 性能设置 → 调整为最佳性能。
虚拟内存调优
虚拟内存(页面文件)管理不好,会严重影响性能。
调整虚拟内存:# 查看当前虚拟内存设置
Get-WmiObject Win32_ComputerSystem Select-Object AutomaticManagedPagefile
关闭自动管理,手动设置
$ComputerSystem = Get-WmiObject Win32_ComputerSystem -EnableAllMembers $ComputerSystem.AutomaticManagedPageFile = $False $ComputerSystem.Put()
设置页面文件为物理内存的1.5倍,最小4GB,最大16GB
$PageFile = Get-WmiObject -Class Win32_PageFileSetting $PageFile.InitialSize = 4096 $PageFile.MaximumSize = 16384 $PageFile.Put()
如果物理内存够大(64GB+),可以考虑完全禁用页面文件:
# 禁用页面文件(内存足够大时)
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" -Name "PagingFiles" -Value ("")
但注意:有些程序(比如SQL Server)会检查页面文件是否存在,建议还是保留。
禁用不必要的启动项
服务器跑久了,启动项越来越多,很多软件偷偷摸摸就加了个自启动。
查看启动项:# 查看开机启动项
Get-CimInstance Win32_StartupCommand Select-Object Name, Command, Location
查看计划任务中的启动任务
Get-ScheduledTask Where-Object {$_.Settings.RunOnlyIfIdle -eq $false -and $_.Settings.Disabled -eq $false}
禁用启动项:
# 禁用指定启动项(以OneDrive为例)
Disable-ScheduledTask -TaskName "OneDrive" -TaskPath "\Microsoft\Windows\OneDrive\"
或者直接运行`msconfig` → 启动标签页 → 禁用不需要的。
清理磁盘和日志
Windows Server运行久了,磁盘空间会被各种临时文件、日志、补丁缓存占满。
一键清理脚本:# 清理临时文件
Remove-Item -Path "$env:TEMP\*" -Recurse -Force -ErrorAction SilentlyContinue
清理Windows更新缓存(谨慎使用,会导致更新重装)
Stop-Service wuauserv
Remove-Item "C:\Windows\SoftwareDistribution\Download\*" -Recurse -Force
Start-Service wuauserv
清理日志文件(只清理旧日志)
Get-ChildItem "C:\Windows\Logs\CBS" -ErrorAction SilentlyContinue Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-30)} Remove-Item -Force -Recurse
清理 IIS 日志(如果用了IIS)
$LogPath = "C:\inetpub\logs\LogFiles" if (Test-Path $LogPath) {
Get-ChildItem $LogPath -Recurse Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-30)} Remove-Item -Force -Recurse
}
网络优化
优化TCP参数:# 开启TCP窗口缩放
netsh int tcp set global autotuninglevel=normal
开启NetBIOS over TCP/IP(局域网需要则开启)
netsh int ip set global nbtenabled=1
调整RSS(Receive Side Scaling)队列数
netsh int tcp set global rss=enabled
开启TCP Chimney Offload
netsh int tcp set global chimney=enabled
调整网卡电源管理:
设备管理器 → 网卡 → 电源管理 → 取消勾选"允许计算机关闭此设备以节约电源"。
一键优化脚本
把所有优化整理成一个PowerShell脚本:
# Windows Server 性能优化脚本
需要管理员权限运行
Write-Host "开始优化..." -ForegroundColor Green
1. 电源计划设为高性能
powercfg /setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c Write-Host "[OK] 电源计划已设为高性能"
2. 关闭不必要服务
$services = @("WSearch", "RemoteRegistry") foreach ($svc in $services) { $service = Get-Service -Name $svc -ErrorAction SilentlyContinue if ($service) { Stop-Service -Name $svc -Force -ErrorAction SilentlyContinue Set-Service -Name $svc -StartupType Disabled -ErrorAction SilentlyContinue } } Write-Host "[OK] 不必要服务已关闭"
3. 关闭视觉效果
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "VisualFXSetting" -Value 2 -Force Write-Host "[OK] 视觉效果已关闭"
4. 清理磁盘(清理7天前的临时文件)
$days = 7 $tempPaths = @("$env:TEMP", "C:\Windows\Temp", "C:\Windows\Logs\CBS") foreach ($path in $tempPaths) { if (Test-Path $path) {
Get-ChildItem $path -Recurse -Force -ErrorAction SilentlyContinue
Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-$days) }
Remove-Item -Force -Recurse -ErrorAction SilentlyContinue } } Write-Host "[OK] 临时文件已清理"
5. 调整虚拟内存为固定8GB
$cs = Get-WmiObject Win32_ComputerSystem $cs.AutomaticManagedPageFile = $False
$cs.Put() Out-Null
$pf = Get-WmiObject Win32_PageFileSetting $pf.InitialSize = 8192 $pf.MaximumSize = 8192
$pf.Put() Out-Null
Write-Host "[OK] 虚拟内存已设为固定8GB"
Write-Host "" Write-Host "优化完成!建议重启服务器使所有设置生效。" -ForegroundColor Yellow
优化效果对比
| 优化项 | 效果 |
| 电源计划高性能 | CPU响应速度提升 |
| 关闭Windows Search | 减少IO和CPU占用 |
| 关闭视觉特效 | 界面响应更快 |
| 禁用启动项 | 开机速度更快 |
| 清理磁盘 | 释放空间,提升IO |
结语
Windows Server性能优化说难也不难,关键是把那些没用的服务和功能关掉,把电源计划、高性能模式开起来。这些改动不会破坏系统稳定性,反而能让服务器跑得更快。上面这些脚本建议保存下来,新装服务器跑一遍,立竿见影。
看完还有什么疑问吗?
如果文章没有覆盖到你的情况,欢迎联系我们咨询——免费解答,说清楚再决定要不要服务。
📞 服务热线:13708730161 💬 微信:eyc1689 📧 邮箱:service@eycit.com 🌐 https://www.eycit.com
易云城IT服务,您身边的IT专家。