Computer >> Hướng Dẫn Máy Tính >  >> Hệ Thống >> Máy Chủ Windows

Cách tắt Windows Error Reporting và xóa thư mục WER\ReportQueue trên Windows

Dịch vụ Windows Error Reporting (WER) thu thập thông tin debug về lỗi hệ thống và ứng dụng thứ 3 và gửi báo cáo lỗi đến server Microsoft. Thông tin này phân tích bởi MSFT và nếu có giải pháp, gửi đến user qua Windows Error Reporting Response. Thực tế ít người dùng tính năng này, mặc dù Microsoft luôn để WER service enabled mặc định trên Windows mới. Đa số người nhớ đến WER khi thấy C:\ProgramData\Microsoft\Windows\WER\ReportQueue\ chiếm nhiều dung lượng ổ hệ thống (lên đến vài chục GB) dù NTFS compression đã bật mặc định cho thư mục này.

Nội dung chính

  • Windows Error Reporting Service
  • Cách xóa thư mục WER\ReportQueue trên Windows
  • Tắt Windows Error Reporting trên Windows Server
  • Cách bật/tắt Error Reporting trên Windows 10
  • Tắt Automatic Windows Error Reporting qua GPO

Windows Error Reporting Service

Windows Error Reporting hiển thị dialog box khi lỗi ứng dụng xảy ra, nhắc gửi báo cáo lỗi đến Microsoft. Khi thấy thông báo "YourAppName.exe has stopped working, Windows is collecting more information about the problem" trên Windows, dịch vụ Windows Error Reporting chạy tool WerFault.exe thu thập debug data (có thể bao gồm memory dump).

Dữ liệu user lưu tại profile: %USERPROFILE%\AppData\Local\Microsoft\Windows\WER\

Dữ liệu hệ thống lưu tại ProgramData: %ALLUSERSPROFILE%\Microsoft\Windows\WER\

Windows Error Reporting service là dịch vụ Windows riêng. Kiểm tra trạng thái dịch vụ bằng PowerShell: Get-Service WerSvc

Trong thư mục WER\ReportQueue\ có nhiều thư mục tên format:

  • Critical_6.3.9600.11285_{ID}_00000000_cab_3212dd23
  • Critical_powershell.exe_{ID}_cab_332a45c5
  • Critical_sqlservr.exe__{ID}_cab_b3a200181
  • NonCritical_7.9.9600.11285__{ID}_0bfab19a
  • AppCrash_cmd.exe_{ID}_dba332ad_12eb5425

Tên thư mục chứa mức độ nghiêm trọng event và tên file EXE cụ thể crash. Tất cả thư mục có file Report.wer chứa mô tả lỗi và file info thêm.

Cách xóa thư mục WER\ReportQueue trên Windows

Thường size mỗi thư mục nhỏ, nhưng đôi khi memory dump cho process vấn đề chiếm lớn. Ảnh dưới size memory.hdmp khoảng 610 MB. Một vài dump như vậy chiếm vài GB trên ổ hệ thống.

Dùng công cụ built-in xóa toàn bộ lỗi và log: Control Panel → System and Security → Security and Maintenance → Maintenance → View reliability history → View all problem reports → Clear all problem reports.

Giải phóng dung lượng ổ nhanh, xóa thủ công file debug/log do WER service tạo tại:

  • C:\ProgramData\Microsoft\Windows\WER\ReportArchive\
  • C:\ProgramData\Microsoft\Windows\WER\ReportQueue\

Lệnh PowerShell xóa file cũ hơn 30 ngày từ thư mục WER:

Get-ChildItem -Path 'C:\ProgramData\Microsoft\Windows\WER\ReportArchive' -Recurse | Where-Object CreationTime -lt (Get-Date).AddDays(-30) | Remove-Item -Force -Recurse
Get-ChildItem -Path 'C:\ProgramData\Microsoft\Windows\WER\ReportQueue' -Recurse | Where-Object CreationTime -lt (Get-Date).AddDays(-30) | Remove-Item -Force –Recurse

Dọn dẹp thư mục WER trong tất cả user profile bằng script PowerShell: $users = Get-ChildItem c:\users|where{$_.name -notmatch 'Public|default'}
foreach ($user in $users){
Get-ChildItem "C:\Users\$User\AppData\Local\Microsoft\Windows\WER\ " –Recurse -ErrorAction SilentlyContinue | Remove-Item –force –Recurse
}

Tắt Windows Error Reporting trên Windows Server

Trên Windows Server 2019/2016/2012R2, quản lý trạng thái WER service bằng PowerShell. Tắt dịch vụ Windows Error Reporting: Get-Service WerSvc| stop-service –passthru -force
Set-Service WerSvc –startuptype manual –passthru

Nhưng có cách tốt hơn tắt WER trên Windows. PowerShell 4.0 thêm module WindowsErrorReporting riêng: Get-Command -Module WindowsErrorReporting

Kiểm tra trạng thái Windows Error Reporting: Get-WindowsErrorReporting

Tắt WER: Disable-WindowsErrorReporting

Trên Windows Server 2012 R2 tắt Windows Error Reporting qua control panel (Control Panel → System and Security → Action Center → Maintenance → Settings → chọn I don't want to participate, and don't ask me again).

Cách bật/tắt Error Reporting trên Windows 10

Trên Windows 10 không tắt Error Reporting qua Control Panel. Kiểm tra trạng thái component tại Control Panel → System & Security → Security and Maintenance → Maintenance. Tham số Report problems đang Enabled.

Tắt Windows Error Reporting trên Windows 10 qua registry. Tạo DWORD (32-bit) parameter tên Disabled giá trị 1 dưới key registry HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting.

Tắt thu thập lỗi Windows cho user cụ thể: reg add "HKCU\Software\Microsoft\Windows\Windows Error Reporting" /v "Disabled" /t REG_DWORD /d "1" /f

Hoặc tắt WER cho tất cả: reg add "HKLM\Software\Microsoft\Windows\Windows Error Reporting" /v "Disabled" /t REG_DWORD /d "1" /f

Kiểm tra lại tham số Report problems trong Control Panel. Nên là Off.

Triển khai tham số registry này đến domain computer qua GPO.

Tắt Automatic Windows Error Reporting qua GPO

Tắt logging bởi Windows Error Reporting service qua Group Policy. Mở local (gpedit.msc) hoặc domain GPO (gpmc.msc) editor đến section Computer Configuration → Administrative Templates → Windows Components → Windows Error Reporting. Tìm policy Disable Windows Error Reporting set Enabled. Sẽ tắt thu thập dữ liệu Windows và báo cáo lỗi.

Có policy tương tự ở section User Configuration.

Cập nhật GPO setting (gpupdate /force) không cần reboot.

Kết quả: Windows không còn tạo thông báo lỗi ứng dụng/hệ thống và không gửi đến Microsoft.