点蓝色复制按钮
先点下方“复制安装命令”。它只会复制文字,不会立刻清理电脑。
不需要下载软件,也不需要懂代码。按下方示意图操作:先创建桌面清理文件,再确认它是不是你的问题。
下面是示意图。Windows 10 和 Windows 11 的位置可能略有不同,但要找的文字是一样的。
先点下方“复制安装命令”。它只会复制文字,不会立刻清理电脑。
按键盘 Windows 键,搜索 PowerShell,右键选择“以管理员身份运行”。
窗口里按 Ctrl + V,再按 Enter。先继续做下方“只读检查”;确认超过 1GB 后,再双击它。
只针对一个 Windows 日志异常变大的问题。先用下方“只读检查”确认,再决定是否创建并运行桌面清理文件。
WalSizeGB 显示 1GB 以上。CapabilityAccessManager.db-wal。打开“我的电脑”,在顶部地址栏粘贴这个路径,然后按 Enter:
如果打不开文件夹,可能只是 Windows 的权限保护。不要因此删除整个文件夹,直接使用下方的“只读检查”更简单。
这段命令只会在桌面创建两个文件:一个负责清理,一个负责请求管理员权限。首次运行不会直接删除目标日志。
$desktop = [Environment]::GetFolderPath('Desktop')
$psScriptPath = Join-Path $desktop 'Clean-CapabilityWal.ps1'
$cmdScriptPath = Join-Path $desktop 'Run-Clean-CapabilityWal-Admin.cmd'
$psScript = @'
# 只处理这个明确的 Windows 日志文件
#requires -RunAsAdministrator
param([switch]$System)
$ErrorActionPreference = 'Stop'
$walPath = 'C:\ProgramData\Microsoft\Windows\CapabilityAccessManager\CapabilityAccessManager.db-wal'
$thresholdBytes = 1GB
$taskName = 'CodexCapabilityWalCleanup'
# 使用 Windows 公共数据目录,不依赖电脑是否有 D 盘
$reportPath = Join-Path $env:ProgramData 'CodexCapabilityWalCleanup.result.txt'
if ($System) {
$wasRunning = $false
$deleted = $false
$beforeGB = $null
$message = ''
try {
$item = Get-Item -LiteralPath $walPath -Force
$beforeBytes = $item.Length
$beforeGB = [math]::Round($beforeBytes / 1GB, 2)
if ($beforeBytes -lt $thresholdBytes) {
$message = '目标日志小于 1 GB,未执行清理。'
} else {
$service = Get-Service -Name camsvc
$wasRunning = $service.Status -eq 'Running'
if ($wasRunning) {
Stop-Service -Name camsvc -Force
Start-Sleep -Seconds 3
}
# 只删除上面指定的 .db-wal 文件,不删除文件夹和主数据库
Remove-Item -LiteralPath $walPath -Force
$deleted = -not [System.IO.File]::Exists($walPath)
$message = '已删除异常日志文件。'
}
} catch {
$message = "执行失败:$($_.Exception.Message)"
} finally {
if ($wasRunning) { Start-Service -Name camsvc -ErrorAction SilentlyContinue }
$freeGB = [math]::Round((Get-CimInstance Win32_LogicalDisk -Filter "DeviceID='C:'").FreeSpace / 1GB, 2)
[PSCustomObject]@{
Result = $message
Deleted = $deleted
RemovedGB = $beforeGB
FreeGB = $freeGB
} | Format-List | Out-File -LiteralPath $reportPath -Encoding utf8
}
exit
}
Remove-Item -LiteralPath $reportPath -Force -ErrorAction SilentlyContinue
$taskCommand = "powershell.exe -NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`" -System"
# 用 Windows 自带任务计划程序临时获取更高权限,完成后立即删除任务
& schtasks.exe /Create /TN $taskName /TR $taskCommand /SC ONCE /ST 23:59 /RU SYSTEM /RL HIGHEST /F | Out-Null
& schtasks.exe /Run /TN $taskName | Out-Null
try {
for ($i = 0; $i -lt 60 -and -not (Test-Path -LiteralPath $reportPath); $i++) { Start-Sleep -Seconds 2 }
if (Test-Path -LiteralPath $reportPath) {
Get-Content -LiteralPath $reportPath
} else {
Write-Host '清理任务未在两分钟内完成,请稍后再次运行桌面文件。'
}
} finally {
& schtasks.exe /Delete /TN $taskName /F | Out-Null
Remove-Item -LiteralPath $reportPath -Force -ErrorAction SilentlyContinue
}
Read-Host '按 Enter 关闭窗口'
'@
$cmdScript = @'
@echo off
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "Start-Process -FilePath powershell.exe -Verb RunAs -ArgumentList '-NoProfile','-ExecutionPolicy','Bypass','-File','%~dp0Clean-CapabilityWal.ps1'"
'@
$psScript | Set-Content -LiteralPath $psScriptPath -Encoding utf8
$cmdScript | Set-Content -LiteralPath $cmdScriptPath -Encoding ascii
Write-Host "已创建:$psScriptPath"
Write-Host "以后请双击:$cmdScriptPath"
$walPath = '...CapabilityAccessManager.db-wal'
指定目标:只看这一条日志
$thresholdBytes = 1GB
安全门槛:小文件不处理
Stop-Service -Name camsvc
暂时停用相关服务
Remove-Item -LiteralPath $walPath
删除异常日志
schtasks.exe /Delete ...
清理临时任务
-ExecutionPolicy Bypass
允许本地脚本运行
把鼠标移到上面的命令行,或点击命令行,就能看到直白说明。
这段命令只读取系统版本、电脑型号和目标文件大小,不会删除文件,也不会联网。
$path = 'C:\ProgramData\Microsoft\Windows\CapabilityAccessManager\CapabilityAccessManager.db-wal'
$os = Get-CimInstance Win32_OperatingSystem
$pc = Get-CimInstance Win32_ComputerSystem
[PSCustomObject]@{
Windows = $os.Caption
Build = $os.BuildNumber
Manufacturer = $pc.Manufacturer
Model = $pc.Model
WalPath = $path
WalSizeGB = try {
[math]::Round((Get-Item -LiteralPath $path -Force -ErrorAction Stop).Length / 1GB, 2)
} catch {
'未找到或当前权限不足'
}
}
如果结果显示“当前权限不足”,不代表文件不存在。请先关闭窗口,不要自己修改权限;确认是同一路径的大文件后,再使用上面的桌面清理文件。
我们在一台 Dell Windows 11 电脑上排查到,Windows 权限记录服务产生的日志文件异常膨胀,单个文件占用了约 157GB。它与摄像头、定位等应用权限记录有关,不是普通照片、视频或 Dell 备份。
微软已经在 Windows 11 的更新中加入了减少这类日志异常占用的改进,但这不等于所有设备都不会再遇到。已经膨胀的旧文件也不一定会自动释放空间,所以仍可能有人遇到类似个案。
这份页面来自一次真实排查,清理脚本在原电脑上验证过,不能宣称所有品牌和版本都已验证。