Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Windows 10 / How to Clear RDP Connections History in Windows?

May 11, 2023 Windows 10Windows 7Windows Server 2016

How to Clear RDP Connections History in Windows?

The built-in Windows Remote Desktop Connection (RDP) client (mstsc.exe) saves the remote computer name (or IP address) and the username that is used to login after each successful connection to the remote computer. On the next start, the RDP client offers the user to select one of the connections that was used previously. The user can select the name of the RDS/RDP host from the list, and the client automatically fills the username used earlier for login.

This is convenient from the end-user perspective, but unsafe from the security point of view. Especially when you connect to your RDP server from a public or untrusted computer.

Information about all RDP (terminal) sessions is stored individually in the registry hive of each user, i.e. a non-admin won’t be able to view the RDP connection history of another user.

history of rdp connections in windows

In this article we will show where Windows stores the history and saved credentials of Remote Desktop connections, how to remove entries from the mstsc window, and clear RDP logs.

Contents:
  • How to Remove RDP Connection Cache from the Registry?
  • Script to Clear RDP Connection History
  • How to Prevent Windows from Saving RDP Connection History?
  • How to Clear Remote Desktop Bitmap Cache?
  • Clearing Saved RDP Credentials
  • Removing RDP-Related Event Logs on a Remote Host

How to Remove RDP Connection Cache from the Registry?

Information about all RDP connections is stored in the registry of each user. It’s impossible to remove a computer (or computers) from the list of RDP connection history using built-in Windows tools. You will have to manually clear some registry keys.

  1. Run the Registry Editor (regedit.exe) and browse to the registry key HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client;
  2. You need two registry keys in this section: Default (stores the history of the last 10 RDP connections) and Servers (contains the list of all RDP servers and usernames used previously to login);mstsc rdp client history in windows registry
  3. Expand the registry key HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Default which contains the list of 10 IP addresses or DNS names of remote computers that have been used recently (MRU – Most Recently Used). The name (or the IP address) of the remote desktop server is stored in the value of the MRU*. parameter. To clear the history of the most recent RDP connections, select all parameters with the names of MRU0-MRU9, right-click and select Delete;remove recent rdp entires from registry
  4. Now expand the key HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Servers. It contains the list of all RDP connections that have ever been established by this user. Expand the reg key with the name (or ip address) of any host. Pay attention to the value of the UsernameHint parameter. It shows the username used to connect to the RDP/RDS host. This username will be used to connect to the RDP host automatically. In addition, the CertHash variable contains the RDP server SSL certificate thumbprint (see the article “Configuring trusted TLS/SSL certificates for RDP”);rdp history in registry: saved host and username
  5. In order to clear the history of all RDP connections and saved usernames, you must clean the contents of Servers registry key. Since it’s impossible to select all nested registry keys at once, it’s easier to delete the entire Servers key and then recreate it manually;delete recent rdp servers in registry
  6. Next you need to delete the default RDP connection file (which contains information about the latest rdp session) – Default.rdp (this file is a hidden file located in Documents directory).
  7. Windows also saves the recent Remote Desktop connections in Jump Lists. If you type mstsc in the Windows 10 search box, the previously used RDP connections will appear in the list. You can completely disable Windows 10 recent file and location in Jump list with the registry dword parameter Start_TrackDocs in the reg key HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced (set it to 0), or you can clear the Resent Items lists by deleting files in the directory %AppData%\Microsoft\Windows\Recent\AutomaticDestinations.rdp: recent items jump lists on windows 10
Note. The described method for clearing the connection history of Remote Desktop works on all Windows desktop versions (from Windows XP to Windows 10) and for Windows Server.

Script to Clear RDP Connection History

Above we have showed how to clear the history of RDP connection in Windows manually. However, doing it manually (especially on multiple computers) is time consuming. Therefore, we offer a small script (BAT file) that allows to automatically clearing the RDP history.

To automate the RDP history cleanup, you can place this script to Windows Startup or run it on user computers via a 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

Let’s consider all the actions of the script:

  1. Disable the output of the information to the console;
  2. Delete all the parameters in the registry key HKCU\Software\Microsoft\Terminal Server Client\Default (clear the list of recent RDP connections);
  3. Delete the entire reg key HKCU\Software\Microsoft\Terminal Server Client\Servers (clears the list of all RDP connection and saved user names);
  4. Recreate the previously deleted registry key;
  5. Change the Default.rdp file attributes in the profile directory of the current user (by default it is Hidden and System);
  6. Delete the Default.rdp file;
  7. Clear Remote Desktop Connection entries from jump list recent items.

In addition, you can clear the history of RDP connections using the following PowerShell script:

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

Note. By the way, the feature of the RDP history cleanup is built into many system and registry “cleaners”, such as, CCleaner, etc.

How to Prevent Windows from Saving RDP Connection History?

If you do NOT want Windows to save the RDP connection history, you must deny writing to the registry key HKCU\Software\Microsoft\Terminal Server Client for all user accounts. First, disable permission inheritance on the specified reg key (Permissions -> Advanced -> Disable inheritance). Then change the registry key ACL by ticking the Deny option for users (but you should understand that this is an unsupported configuration).

prevent windows from saving rdp history in registry

As a result, mstsc.exe simply cannot write RDP connection info to the registry.

How to Clear Remote Desktop Bitmap Cache?

The Remote Desktop Connection client has image persistent bitmap caching feature. The RDP client saves rarely changing fragments of the remote screen as a raster image cache. Thanks to this, the mstsc.exe client loads parts of the screen that have not changed since the last rendering from the local drive cache. This RDP caching feature reduces the amount of data transmitted over the network.

RDP cache is two types of files in a directory %LOCALAPPDATA%\Microsoft\Terminal Server Client\Cache:

  • *.bmc
  • bin

rdp bitmap cache files: bmc and bin

These files store raw RDP screen bitmaps in the form of 64×64 pixel tiles. Using simple PowerShell or Python scripts (easily searched for by the RDP Cached Bitmap Extractor query), you can get PNG files with pieces of the remote desktop screen and use them to get sensitive information. The size of the tiles is small, but sufficient to provide useful information to a person studying the RDP cache.

extract png image from rdp cache files RDP Cached Bitmap Extractor

You can prevent the RDP client from storing the remote desktop screen image cache by disabling the Persistent bitmap caching option on the Advanced tab.

rdc (mstsc) client: disable bitmap caching

Sometimes when using the RDP cache, it may be damaged:

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

In this case, you need to clear the RDP cache directory or disable the Bitmap Caching option.

Clearing Saved RDP Credentials

If when establishing a new remote RDP connection, before entering the password, the user checks an option Remember Me, then the username and password will be saved in the Windows Credential Manager. The next time you connect to the same computer, the RDP client automatically uses the previously saved password for authentication on the remote host.

mstsc can save rdp credentials

You can remove the saved RDP password directly from the client’s mstsc.exe window. Select the same connection from the list of connections, and click on the Delete button. Then confirm deletion of the saved credentials.

More details on how RDP saved passwords work in the article at the link.

delete saved rdp credentials

Alternatively, you can delete the RDP saved password directly from the Windows Credential Manager. Go to the Control Panel\User Accounts\Credential Manager section. Select Manage Windows Credentials and in the list of saved passwords find the computer name (in the following format TERMSRV/192.168.1.100). Expand the found item and click the Remove button.

remove remote desktop credentials from credential manager

In an Active Directory domain environment, you can disable saving passwords for RDP connections by using the special GPO – Network access: Do not allow storage of passwords and credentials for network authentication (see an article).

Removing RDP-Related Event Logs on a Remote Host

Connection logs are also saved on the RDP/RDS host side. You can find information about RDP connection history in Event Viewer logs:

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

rdp event TerminalServices-LocalSessionManager

Read more about the analysis of RDP connection logs in the article.

You can clear the Event Logs on an RDP server using wevtutil or PowerShell.

10 comments
6
Facebook Twitter Google + Pinterest
previous post
MBR2GPT: Converting MBR to GPT Disk in Windows 10
next post
How to Manage Services & Scripts Startup on CentOS/RHEL?

Related Reading

Zabbix: How to Get Data from PowerShell Scripts

October 27, 2023

Tracking Printer Usage with Windows Event Viewer Logs

October 19, 2023

How to Use Ansible to Manage Windows Machines

September 25, 2023

Installing Language Pack in Windows 10/11 with PowerShell

September 15, 2023

How to View and Change BIOS (UEFI) Settings...

September 13, 2023

10 comments

Gray Fox March 17, 2017 - 2:13 pm

Thanks for your post. I was looking to clear the last connection, and deleting the default.rdp file helped in that regard. Thanks again!

Reply
robertson thomas October 18, 2018 - 12:04 pm

I am still getting the username once I login to the RDP

Reply
Vahid March 27, 2019 - 2:53 pm

go to “Documents” folder and delete “Default.rdp”

Reply
Telbus April 24, 2019 - 7:06 am

In windows 10 there is still a recent connection list when you search RDP in bottom search bar and it brings the RDP client app in the result. How to clear that too?

Reply
Pirulo November 1, 2019 - 1:44 pm

Thanks, it worked.

Reply
adm January 1, 2020 - 9:54 pm

still leaves sum info on the resents on windows 10

Reply
Mahair June 3, 2020 - 1:18 pm

Is there a way to prevent RDP from caching remote computer name
I do not want RDP to cache remote computer name at all

Reply
DNT February 23, 2021 - 3:50 am

Thanks for publishing this forum. It was very helpful to me.

Reply
venkatarangaN July 13, 2021 - 9:54 am

Thanks, the script worked and saved a lot of time

Reply
Piyush September 5, 2022 - 8:36 am

Hello,

This batch file does not work on Windows 11. Is there a way to make it work on Windows 11? Please help me out. Please

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023
  • How to Use Ansible to Manage Windows Machines

    September 25, 2023
  • Installing Language Pack in Windows 10/11 with PowerShell

    September 15, 2023
  • Configure Email Forwarding for Mailbox on Exchange Server/Microsoft 365

    September 14, 2023
  • How to View and Change BIOS (UEFI) Settings with PowerShell

    September 13, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • How to Disable UAC Prompt for Specific Applications in Windows 10?
  • How to Download APPX File from Microsoft Store for Offline Installation?
  • Fix: Windows Cannot Connect to the Shared Printer
  • How to Clean Up Large System Volume Information Folder on Windows?
  • Fixing “Winload.efi is Missing or Contains Errors” in Windows 10
  • How to Hide Installed Programs in Windows 10 and 11
  • Windows Doesn’t Automatically Assign Drive Letters
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top