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

Cách xóa lịch sử kết nối RDP trong Windows

Client Remote Desktop Connection (RDP) tích hợp Windows (mstsc.exe) lưu tên máy tính (hoặc IP) và username sau mỗi kết nối thành công đến máy chủ từ xa. Lần khởi động sau, RDP client gợi ý chọn từ các kết nối đã dùng. User chọn tên RDS/RDP host từ danh sách, client tự điền username đã dùng trước.

Tiện lợi cho user nhưng không an toàn về bảo mật, đặc biệt khi kết nối RDP server từ máy công cộng/không tin cậy.

Thông tin tất cả phiên RDP (terminal) lưu riêng trong registry hive của từng user → non-admin không xem được lịch sử RDP của user khác.

Cách xóa lịch sử kết nối RDP trong Windows

Bài viết chỉ nơi Windows lưu lịch sử và credential RDP, cách xóa entry từ cửa sổ mstsc, và xóa log RDP.

Xóa cache kết nối RDP từ Registry

Thông tin RDP lưu trong registry của user. Không có công cụ tích hợp xóa máy tính khỏi lịch sử RDP. Phải xóa thủ công registry key.

  1. Mở Registry Editor (regedit.exe) → khóa HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client.
  2. Cần 2 khóa: Default (lịch sử 10 kết nối RDP gần nhất - MRU) và Servers (danh sách tất cả RDP server và username đã dùng).
    Cách xóa lịch sử kết nối RDP trong Windows
  3. Mở rộng HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Default → danh sách 10 IP/DNS remote gần nhất (MRU). Tên/IP lưu ở giá trị MRU*. Xóa lịch sử gần nhất: chọn tất cả tham số MRU0-MRU9, chuột phải → Delete.
    Cách xóa lịch sử kết nối RDP trong Windows
  4. Mở rộng khóa HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Servers. Chứa tất cả kết nối RDP từng thiết lập. Mở rộng khóa tên/IP host bất kỳ. Chú ý giá trị UsernameHint — username dùng để kết nối RDP/RDS (sẽ dùng tự động lần sau). Biến CertHash chứa thumbprint SSL certificate của RDP server (xem bài Configuring trusted TLS/SSL certificates for RDP).
    Cách xóa lịch sử kết nối RDP trong Windows
  5. Để xóa toàn bộ lịch sử RDP và username đã lưu: xóa toàn bộ nội dung khóa Servers. Vì không chọn được nhiều nested key cùng lúc, dễ nhất xóa toàn bộ khóa Servers rồi tạo lại thủ công.
    Cách xóa lịch sử kết nối RDP trong Windows
  6. Xóa file kết nối RDP mặc định (chứa info phiên RDP mới nhất) — Default.rdp (file ẩn trong thư mục Documents).
  7. Windows cũng lưu recent RDP connections trong Jump Lists. Gõ mstsc trong search Windows 10 → kết nối trước hiện ra. Tắt hoàn toàn recent file/location trong Jump list: registry DWORD Start_TrackDocs trong HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced = 0. Hoặc xóa file trong %AppData%\Microsoft\Windows\Recent\AutomaticDestinations.
    Cách xóa lịch sử kết nối RDP trong Windows

Lưu ý: Cách xóa lịch sử RDP này hoạt động trên mọi phiên bản Windows desktop (XP đến 10) và Windows Server.

Script tự động xóa lịch sử RDP

Làm thủ công (đặc biệt trên nhiều máy) tốn thời gian. Dưới đây script BAT tự động xóa lịch sử RDP.

Đặt script vào Windows Startup hoặc chạy qua GPO logoff script.

@echo off
reg delete "HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Default" /va /f
reg delete "HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Servers" /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Servers"
attrib -s -h %userprofile%\documents\Default.rdp
del %userprofile%\documents\Default.rdp
del /f /s /q /a %AppData%\Microsoft\Windows\Recent\AutomaticDestinations

Giải thích script:

  1. Tắt output console;
  2. Xóa tất cả tham số trong HKCU\...\Default (xóa recent RDP);
  3. Xóa toàn bộ khóa HKCU\...\Servers (xóa all RDP connections + username);
  4. Tạo lại khóa Servers;
  5. Bỏ thuộc tính Hidden/System của Default.rdp trong profile user;
  6. Xóa Default.rdp;
  7. Xóa entry RDP từ Jump List recent items.

PowerShell script thay thế:

Get-ChildItem "HKCU:\Software\Microsoft\Terminal Server Client" -Recurse | Remove-ItemProperty -Name UsernameHint -Ea 0
Remove-Item -Path 'HKCU:\Software\Microsoft\Terminal Server Client\servers' -Recurse 2>&1 | Out-Null
Remove-ItemProperty -Path 'HKCU:\Software\Microsoft\Terminal Server Client\Default' 'MR*' 2>&1 | Out-Null
$docs = [environment]::getfolderpath("mydocuments") + '\Default.rdp'
remove-item $docs -Force 2>&1 | Out-Null

Lưu ý: Tính năng xóa lịch sử RDP có sẵn trong nhiều tool dọn dẹp hệ thống/registry như CCleaner.

Ngăn Windows lưu lịch sử RDP

Nếu KHÔNG muốn Windows lưu lịch sử RDP, từ chối ghi vào khóa registry HKCU\Software\Microsoft\Terminal Server Client cho tất cả user. Tắt inheritance permission trên khóa reg (Permissions → Advanced → Disable inheritance). Sửa ACL khóa reg tick Deny cho users (hiểu đây là cấu hình không được hỗ trợ chính thức).

Cách xóa lịch sử kết nối RDP trong Windows

Kết quả: mstsc.exe không ghi được info RDP vào registry.

Xóa Remote Desktop Bitmap Cache

RDP client có tính năng persistent bitmap caching. Client lưu các đoạn màn hình remote ít thay đổi dưới dạng raster image cache. Nhờ đó mstsc load phần màn hình không đổi từ cache local → giảm băng thông mạng.

RDP cache gồm 2 loại file trong %LOCALAPPDATA%\Microsoft\Terminal Server Client\Cache:

  • *.bmc
  • *.bin

Cách xóa lịch sử kết nối RDP trong Windows

File lưu raw RDP screen bitmap dạng tile 64×64 pixel. Dùng script PowerShell/Python (tìm RDP Cached Bitmap Extractor) xuất PNG các mảnh màn hình remote → có thể lấy thông tin nhạy cảm. Kích thước tile nhỏ nhưng đủ cung cấp info hữu ích.

Cách xóa lịch sử kết nối RDP trong Windows

Ngăn RDP client lưu cache màn hình: tắt tùy chọn Persistent bitmap caching trên tab Advanced.

Cách xóa lịch sử kết nối RDP trong Windows

Đôi khi RDP cache bị hỏng:

Bitmap Disk Cache Failure. Your disk is full or the cache directory is missing or corrupted. Some bitmaps may not appear.

Lúc này xóa thư mục RDP cache hoặc tắt Bitmap Caching.

Xóa RDP Credentials đã lưu

Khi tạo kết nối RDP mới, tick Remember Me trước khi nhập password → username/password lưu trong Windows Credential Manager. Lần sau kết nối cùng máy, RDP client tự dùng password đã lưu.

Cách xóa lịch sử kết nối RDP trong Windows

Xóa saved RDP password trực tiếp từ cửa sổ mstsc.exe: chọn connection trong danh sách → nhấn Delete → xác nhận xóa credential.

Cách xóa lịch sử kết nối RDP trong Windows

Chi tiết cách hoạt động RDP saved password xem bài liên kết.

Hoặc xóa từ Windows Credential Manager: Control Panel → User Accounts → Credential Manager → Manage Windows Credentials → tìm tên máy (format TERMSRV/192.168.1.100) → Expand → Remove.

Cách xóa lịch sử kết nối RDP trong Windows

Trong môi trường Active Directory domain, tắt lưu password RDP bằng GPO: Network access: Do not allow storage of passwords and credentials for network authentication (xem bài liên quan).

Xóa Event Log liên quan RDP trên Remote Host

Log kết nối cũng lưu phía RDP/RDS host. Tìm lịch sử RDP trong Event Viewer:

  • Security;
  • Applications and Services Logs → Microsoft → Windows → TerminalServices-RemoteConnectionManager → Operational;
  • TerminalServices-LocalSessionManager → Admin.

Cách xóa lịch sử kết nối RDP trong Windows

Đọc thêm về phân tích log RDP trong bài liên kết.

Xóa Event Log trên RDP server dùng wevtutil hoặc PowerShell.