Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

How to Clear RDP Connections History in Windows?

February 20, 2024
in Blog
0
ADVERTISEMENT

Table of Contents

The built-in Windows Remote Desktop Connection client (mstsc.exe) saves the remote computer name (or IP address) and the username that is used to log in after each successful connection to the remote RDP host. 

The next time the RDP client starts, the user can select one of the saved connections and the previous username is automatically inserted. If you are using a public computer or a computer you don’t trust, you may want to clear your RDP connection history for security reasons.

HSo7BekP66oC47gGsv8m3cA2FnyKLLLNpaJea1WUldFwubPMmWGFA1cwK6w5

This article describes where Windows stores Remote Desktop connection history and credentials, and how to clear RDP history and logs.

Delete RDP Connection History from Registry

Windows stores the history of Remote Desktop client connections in several different places, and to completely clear the RDP history you will need to delete the data from all of these places.

1. Open the Registry Editor (regedit.exe) and go to the below reg key.

HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client

2. The Default subkey contains history entries for the last 10 RDP connections. The names of the parameters are MRU0-MRU9 (MRU – Most Recently Used). Their values contain IP addresses/RDP host names. Select all the registry parameters in the key and delete them.

OYRDGYVTA9gGQV1SxZA5Cs8LzoWxjXyejlFVhBiZELGe0US7Ug30R61TwzpV

3. Expand the Servers subkey. A list of all previously used RDP hosts and user accounts is stored here.

  • The username is contained in the UsernameHint parameter. This username is automatically inserted into the mstsc.exe client window when you connect to this RDP host.
  • The CertHash parameter contains the thumbprint of the server’s RDP certificate.
4nmEX6H67hSo3LeHqC7KauMrQnov3ogtsvge3SjbnDXeUbePV3ffwmqYy104

4. Clear all entries in the Servers registry key. The easiest way to do this is to simply delete the entire Servers reg key, and then re-create it manually.

153dGLxDoflxFKC7S1gi1yXvcrTiuas31lz7mc41BssWNMX7rQDfmY6T3DRm

Delete the Default.RDP File

The next step is to delete the hidden Default.rdp file from the %userprofile%\Documents folder in the user profile. This file stores information about the last RDP connection.

%userprofile%\Documents
rTLnxpaDnRqqccRaa0Kj3pWUKU9bngXGsEJ3pJ5GVIHFu6nORWZP4LmBIulr

Related: How to Show Hidden Files on Windows 11

Delete Recent RDP History from the Start Menu and Taskbar

Windows also stores recent remote desktop connections in Jump Lists. If you type mstsc in the Windows search box or right-click on the client in the taskbar, you will see the history of previous RDP connections in the Recent list.

tTJ3NfgUXx1HYDIx3rAlbnTfoPJMrnsCLhMEkrWwDTzVOvomSgFemFTcTPyp

To clear the RDP history in the Start Menu and Jump Lists, clear the Recent Items list by deleting the files in the below folder.

%AppData%\Microsoft\Windows\Recent\AutomaticDestinations
veKwbkeXE3au75vEpMHNEdbfhZ6k0k67KdmF4pxEnVPdUTB7ocjqMiqHxRUZ

If you don’t want to do it manually, let’s simply open PowerShell and then execute the following commands. It’ll delete all files in that folder automatically.

# Delete Recent RDP History Entries from the Start Menu and Taskbar
$filePath = "$env:APPDATA\Microsoft\Windows\Recent\AutomaticDestinations"
Remove-Item $filePath\*.automaticDestinations-ms -Force

Clear RDP Event Viewer Logs in Windows

The RDP client also logs each outbound connection to the Event Viewer log (Applications and Services Logs -> Microsoft -> Windows -> TerminalServices-ClientActiveXCore -> Microsoft-Windows-TerminalServices-RDPClient/Operational).

R6FBK7xLg8svXI0IzBaiqITFtn1Bh0doky58pxZK6vRWG3aiFU010JEjNtba

To list the log for outbound RDP client connections, use the Get-WinEvent PowerShell cmdlet to select and filter the events in the Event Viewer:

$properties = @(
    @{n='TimeStamp';e={$_.TimeCreated}}
    @{n='LocalUser';e={$_.UserID}}
    @{n='Target RDP host';e={$_.Properties[1].Value}}
)

$logName = 'Microsoft-Windows-TerminalServices-RDPClient/Operational'
Get-WinEvent -FilterHashTable @{LogName=$LogName;ID='1102'} | Select-Object $properties
# Output
TimeStamp             LocalUser                                      Target RDP host
---------             ---------                                      ---------------
2/15/2024 10:23:02 PM S-1-5-21-2408781006-1476909924-2351602277-1000 20.205.174.224
2/15/2024 10:22:53 PM S-1-5-21-2408781006-1476909924-2351602277-1000 20.6.96.132
2/15/2024 10:22:42 PM S-1-5-21-2408781006-1476909924-2351602277-1000 20.6.96.48
2/15/2024 10:08:30 PM S-1-5-21-2408781006-1476909924-2351602277-1000 20.6.96.48
2/15/2024 10:07:08 PM S-1-5-21-2408781006-1476909924-2351602277-1000 20.6.96.48
2/15/2024 10:06:10 PM S-1-5-21-2408781006-1476909924-2351602277-1000 20.6.96.132
2/15/2024 10:05:04 PM S-1-5-21-2408781006-1476909924-2351602277-1000 20.6.96.132
2/15/2024 9:40:55 PM  S-1-5-21-2408781006-1476909924-2351602277-1000 20.6.96.132
2/15/2024 9:27:14 PM  S-1-5-21-2408781006-1476909924-2351602277-1000 20.6.96.48
2/15/2024 9:27:10 PM  S-1-5-21-2408781006-1476909924-2351602277-1000 20.205.174.224
2/15/2024 9:27:01 PM  S-1-5-21-2408781006-1476909924-2351602277-1000 20.6.96.132
2/15/2024 9:18:22 PM  S-1-5-21-2408781006-1476909924-2351602277-1000 20.6.96.48
2/15/2024 9:18:12 PM  S-1-5-21-2408781006-1476909924-2351602277-1000 20.205.174.224
2/15/2024 9:18:02 PM  S-1-5-21-2408781006-1476909924-2351602277-1000 20.6.96.48
2/15/2024 9:17:32 PM  S-1-5-21-2408781006-1476909924-2351602277-1000 20.6.96.48
2/15/2024 6:47:51 PM  S-1-5-21-2408781006-1476909924-2351602277-1000 20.6.96.132
2/15/2024 6:47:05 PM  S-1-5-21-2408781006-1476909924-2351602277-1000 20.205.174.224
2/15/2024 6:45:59 PM  S-1-5-21-2408781006-1476909924-2351602277-1000 20.6.96.48

We can clear this event log from the Event Viewer console or by using the command:

WevtUtil cl Microsoft-Windows-TerminalServices-RDPClient/Operational

When running the script to list the log for outbound RDP client connections again, make sure you get the error No events were found. It means all logs have been deleted.

mN9NNHmie7yze2QB0hbvXF2RuhgVeJ6O1xXPSc5zQnIHKtZgVjJOyP5ek6qz

How to Clear Remote Desktop Bitmap Cache?

By default, the mstsc.exe client caches rarely modified areas of the remote desktop as bitmaps (persistent bitmap caching). The RDP client cache can significantly reduce network traffic.

The RDP client cache is stored in *.bmc and *.bin files in the following location.

%LOCALAPPDATA%\Microsoft\Terminal Server Client\Cache

For security reasons, it is recommended that you clear the RDP cache folder and prevent the RDP client from saving the screen image to the cache. Go to that folder and delete all files.

JNjFVlQk256drALwqmNtyJkDfKDI4lUqmEEjmnQpTf1da5smv8nRQAl2jtgj

You can disable the Persistent bitmap caching option on the Advanced tab of the Remote Desktop Connection client.

QYfRjw33JqcVfdeithLfpgbjb0xTjbwo01RfEsDVe9puFJ4obiVB6gfXUVpU

Script to Clear RDP Connection History

To quickly clear the history of RDP connections in Windows, you can use a batch script. This script will automatically perform the manual actions described above to clear the connection history and the RDP logs.

@echo off
::Remove the history from Registry 
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"

::Clear information about the last RDP connection
attrib -s -h %userprofile%\documents\Default.rdp
del %userprofile%\documents\Default.rdp

::Delete Recent RDP History Entries from the Start Menu and Taskbar
del /f /s /q /a %AppData%\Microsoft\Windows\Recent\AutomaticDestinations

::Clear the log for outbound RDP client connections
WevtUtil cl Microsoft-Windows-TerminalServices-RDPClient/Operational

::Clear Remote Desktop bitmap cache
del "%LOCALAPPDATA%\Microsoft\Terminal Server Client\Cache\*.bin"
del "%LOCALAPPDATA%\Microsoft\Terminal Server Client\Cache\*.bmc"

::Restart File Explorer
taskkill /im explorer.exe /f & explorer.exe

A similar PowerShell script to clear all entries in the Remote Desktop Connection history:

# Remove the history from Registry 
$regPath = "HKCU:\Software\Microsoft\Terminal Server Client"
Get-ChildItem $regPath -Recurse | Remove-ItemProperty -Name UsernameHint -Ea 0
Remove-Item -Path "$regPath\servers" -Recurse  2>&1 | Out-Null

# Clear information about the last RDP connection
Remove-ItemProperty -Path "$regPath\Default" 'MR*'  2>&1 | Out-Null
$docs = [environment]::getfolderpath("mydocuments") + '\Default.rdp'
Remove-Item $docs -Force  2>&1 | Out-Null

# Delete Recent RDP History Entries from the Start Menu and Taskbar
$filePath = "$env:APPDATA\Microsoft\Windows\Recent\AutomaticDestinations"
Remove-Item $filePath\*.automaticDestinations-ms -Force

# Clear the log for outbound RDP client connections
WevtUtil cl Microsoft-Windows-TerminalServices-RDPClient/Operational

# Clear Remote Desktop bitmap cache
$cachePath = "$env:LOCALAPPDATA\Microsoft\Terminal Server Client\Cache"
Remove-Item $cachePath\*.bmc -Force
Remove-Item $cachePath\*.bin -Force

# Restart File Explorer
Stop-Process -Name "explorer" -Force

Remove Saved RDP Credentials on Windows

The RDP client allows you to store the user’s password in the built-in Windows Credential Manager and automatically connect to a remote host without entering a password.

You can delete saved RDP passwords from the Credential Manager window. Run the command below then remove all entries prefixed TERMSRV\.

rundll32.exe keymgr.dll,KRShowKeyMgr
sRXH3yT3Wsxu5guQKezTgVHsBXQZZfyjaUxBTLqHC5pLSUAtwmboGCShwj0l

Or you can clear the stored credentials for RDP with the command:

For /F "tokens=1,2 delims= " %G in ('cmdkey /list ^| findstr "target=TERMSRV"') do cmdkey /delete %H

Conclusion

The above steps will help you to remove the Remote Desktop Connection History on Windows systems.

ADVERTISEMENT

Not a reader? Watch this related video tutorial:

5/5 - (1 vote)
Previous Post

How to Add Item to the Path Variables Using PowerShell

Next Post

How to Check the Language Code of a Windows ISO Image

Related Posts

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024
Ftr19

How to Fix Windows Cannot Read the ProductKey From the Unattend Answer File in VirtualBox

July 26, 2024
Ftr25

How to Update Windows Terminal in Windows 10/11

July 26, 2024

How to Disable The Beep Sound in WSL Terminal on Windows

July 26, 2024

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory