脚本介绍
命令行的 WMI 客户端工具
优化系统时间
优化磁盘性能
优化内存管理
优化网络连接
优化事件日志
关闭系统还原
Win10系统优化
bat脚本、把以下脚本复制到记事本另存为
文件.bat
右键管理员运行。
@echo off
REM 检测系统版本
ver | findstr /i "10\."
IF %ERRORLEVEL% NEQ 0 (
echo 此脚本仅适用于 Windows 10 及以上版本的操作系统。
pause
exit
)
REM 检测管理员权限
net session >nul 2>&1
IF %ERRORLEVEL% NEQ 0 (
echo 此脚本需要管理员权限运行,请使用管理员身份运行此脚本。
pause
exit
)
REM 设置环境变量 命令行的 WMI 客户端工具
setx /M PATH "%PATH%;C:\Windows\System32\Wbem"
REM 优化时间同步
echo 正在优化时间同步...
net stop W32Time
w32tm /unregister
w32tm /register
net start W32Time
w32tm /resync
REM 优化磁盘性能
echo 正在优化磁盘性能...
fsutil behavior set disablelastaccess 1
fsutil behavior set disable8dot3 1
fsutil behavior set disablecompression 1
REM 优化内存管理
echo 正在优化内存管理...
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v DisablePagingExecutive /t REG_DWORD /d 1 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v LargeSystemCache /t REG_DWORD /d 1 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v IoPageLockLimit /t REG_DWORD /d 16384 /f
REM 关闭系统还原
echo 正在关闭系统还原...
wmic.exe /namespace:\\root\default Path SystemRestore Call Disable
REM 优化网络连接
echo 正在优化网络连接...
netsh interface tcp set global autotuning=disabled
netsh interface tcp set global rss=disabled
netsh interface tcp set global chimney=disabled
REM 优化事件日志
echo 正在优化事件日志...
wevtutil sl Microsoft-Windows-Kernel-EventTracing/Debug 16384
wevtutil sl Microsoft-Windows-Kernel-WHEA/Operational 16384
wevtutil sl Microsoft-Windows-Ntfs/Operational 16384
echo 优化完成!请重新启动计算机以应用更改。
pause
Win10系统清理
PowerShell脚本
检测脚本的先决条件
检查脚本的文件执行策略、Windows 设置为限制运行未签名的脚本。你可以使用以下命令修改执行策略。
Set-ExecutionPolicy RemoteSigned
保存一下脚本为
文件.ps1
使用管理员运行
或者 保存脚本为 myScript.ps1
在命令行窗口找到脚本路径 .\myScript.ps1
运行
# 清理临时文件
Remove-Item -Path "$env:TEMP\*" -Force -Recurse
# 清理回收站
Clear-RecycleBin -Force
# 清理系统日志
wevtutil.exe cl System /quiet
wevtutil.exe cl Application /quiet
wevtutil.exe cl Security /quiet
# 清理 Windows 更新备份文件
Dism.exe /Online /Cleanup-Image /StartComponentCleanup /ResetBase
# 清理更新下载缓存
net stop wuauserv
Remove-Item -Path "$env:WINDIR\SoftwareDistribution\Download\*" -Force -Recurse
net start wuauserv
# 清理临时文件夹
Remove-Item -Path "$env:WINDIR\Temp\*" -Force -Recurse
# 清理浏览器缓存(Chrome)
$chromeCachePath = "$env:LOCALAPPDATA\Google\Chrome\User Data\Default\Cache"
Remove-Item -Path $chromeCachePath -Force -Recurse
# 清理浏览器缓存(Edge)
$edgeCachePath = "$env:LOCALAPPDATA\Microsoft\Edge\User Data\Default\Cache"
Remove-Item -Path $edgeCachePath -Force -Recurse
Win10系统C盘我的文档备份
PowerShell脚本
请手动修改备份目标磁盘的位置
$sourcePath = "$env:USERPROFILE\Documents"
$destinationPath = "D:\Backup\Documents"
Copy-Item -Path $sourcePath -Destination $destinationPath -Recurse -Force
Win10图标盾牌隐藏
# 注册表中添加一个键值对,将文件夹图标更改为编号为29的图标
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons" /v 29 /d "%systemroot%\system32\imageres.dll,197" /t reg_sz /f
# 在注册表中添加另一个键值对,将文件夹图标更改为编号为77的图标
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons" /v 77 /d "%systemroot%\system32\imageres.dll,197" /t reg_sz /f
# 强制结束资源管理器(Windows Explorer)进程
taskkill /f /im explorer.exe
# 更改 iconcache.db 文件的属性,去除系统、只读和隐藏属性
attrib -s -r -h "%userprofile%\AppData\Local\iconcache.db"
# 删除 iconcache.db 文件,参数/f表示强制删除,/q表示静默删除。
del "%userprofile%\AppData\Local\iconcache.db" /f /q
# 启动资源管理器(Windows Explorer)进程,以使更改生效
start explorer
Win10修复图片查看器无法预览图片
@echo off&cd\&color 0a&cls
echo 恢复Win10照片查看器
# 在注册表中添加或修改一个键值对,将.jpg .jpge .bmp .png文件关联到"照片查看器"应用程序
reg add "HKLM\SOFTWARE\Microsoft\Windows Photo Viewer\Capabilities\FileAssociations" /v ".jpg" /t REG_SZ /d PhotoViewer.FileAssoc.Tiff /f
reg add "HKLM\SOFTWARE\Microsoft\Windows Photo Viewer\Capabilities\FileAssociations" /v ".jpeg" /t REG_SZ /d PhotoViewer.FileAssoc.Tiff /f
reg add "HKLM\SOFTWARE\Microsoft\Windows Photo Viewer\Capabilities\FileAssociations" /v ".bmp" /t REG_SZ /d PhotoViewer.FileAssoc.Tiff /f
reg add "HKLM\SOFTWARE\Microsoft\Windows Photo Viewer\Capabilities\FileAssociations" /v ".png" /t REG_SZ /d PhotoViewer.FileAssoc.Tiff /f
echo 请双击或右击图片,选择“照片查看器”即可
pause
禁止Win10系统更新
# 清空命令行窗口的输出
Clear-Host
# 定义注册表路径变量,用于存储Windows更新相关的注册表路径
$WindowsUpdatePath = "HKLM:SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\"
# 定义注册表路径变量,用于存储Windows自动更新相关的注册表路径
$AutoUpdatePath = "HKLM:SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU"
# 判断指定路径是否存在,如果存在则删除该路径及其子项
If(Test-Path -Path $WindowsUpdatePath) {
Remove-Item -Path $WindowsUpdatePath -Recurse
}
# 创建新的注册表项,路径为WindowsUpdatePath。使用-Force参数强制创建(如果已存在则覆盖)
New-Item $WindowsUpdatePath -Force
# 创建新的注册表项,路径为AutoUpdatePath。使用-Force参数强制创建(如果已存在则覆盖)
New-Item $AutoUpdatePath -Force
# 在AutoUpdatePath路径下,设置名为NoAutoUpdate的属性值为1,以禁止自动更新
Set-ItemProperty -Path $AutoUpdatePath -Name NoAutoUpdate -Value 1
# 获取路径为\Microsoft\Windows\WindowsUpdate\的计划任务,并将其禁用
Get-ScheduledTask -TaskPath "\Microsoft\Windows\WindowsUpdate\" | Disable-ScheduledTask
# 获取指定目录的所有者权限
takeown /F C:\Windows\System32\Tasks\Microsoft\Windows\UpdateOrchestrator /A /R
# 修改指定目录的访问控制列表(ACL),将Administrators组的权限设置为完全控制
icacls C:\Windows\System32\Tasks\Microsoft\Windows\UpdateOrchestrator /grant Administrators:F /T
# 获取路径为\Microsoft\Windows\UpdateOrchestrator\的计划任务,并将其禁用
Get-ScheduledTask -TaskPath "\Microsoft\Windows\UpdateOrchestrator\" | Disable-ScheduledTask
# 停止Windows更新服务(Windows Update)
Stop-Service wuauserv
# 将Windows更新服务的启动类型设置为禁用,以防止其在系统启动时自动运行
Set-Service wuauserv -StartupType Disabled
# 输出字符串"含义"
Write-Output "含义"