Windows OS Hub
  • Windows Server
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Group Policies
  • Windows Clients
    • Windows 10
    • Windows 8
    • Windows 7
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
  • PowerShell
  • Exchange
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Group Policies
  • Windows Clients
    • Windows 10
    • Windows 8
    • Windows 7
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
  • PowerShell
  • Exchange

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

March 1, 2018 Windows 10Windows 7

How to Clear RDP Connections History in Windows

For each successful connection to a remote computer, an RDP client in Windows (mstsc.exe) saves remote computer name (or an IP address) and the username used to log on. 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 remote rdp server from the list , and the client automatically fills the user name used for log in.

This is convenient from the end-user perspective, but unsafe from the security point of view, especially when the rdp connection is initiated from a public or untrusted computer.

Information about remote desktop (terminal) sessions is stored individually in the profile of each user, i.e. a user (assuming an ordinary user, not an administrator) can’t view the RDP connection history of another user.

history of rdp connections in windows

In this article we will explain where Windows stores the history of Remote Desktop connections and saved credentials, and how to clear it.

Contents:
  • How to delete RDP connections cache from the registry
  • How to clear the RDP connection history using a script
  • Clearing cached RDP credentials

How to delete RDP connections 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 connections using built-in Windows tools, you will have to manually delete some registry keys.

  1. Run the registry editor regedit.exe and navigate to the HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Clientrdp client history in registry
  2. You need two registry keys – Default (stores the history of the last 10 rdp connections) and Servers (contains the list of all rdp servers and usernames used previously to log in);
  3. Expand registry key HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Default which contains the list of 10 IP addresses or DNS names of remote rdp servers that have been used recently (MRU –  Most Recently Used). The name (or the IP address) of the remote desktop server is kept in the value of the key MRU*. To clear the history of the most recent rdp connections, select all values with the names of MRU0-MRU9, right-click and select Delete;delete rdp Most Recently Used entries
  4. Next, expand HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Servers. It contains the list of all RDC (remote desktop client) connections that have ever been established from this computer. If you expand the node with the name (or ip address) of any server, the UsernameHint key (hints the user name) shows the name of the user connected through rdp;
  5. To clear the history of all rdp connections and saved user names, you must clean the contents of Servers registry key. Since it’s impossible to select all the registry keys at once, it’s easier to delete the entire Servers key and then recreate it manually;registry key rdp username
  6. In addition to the specified registry keys, you need to delete the default rdp connection file (which contains information about the latest rdp session) stored in Default.rdp (this file is a hidden file located in Documents directory).
Note. The described method to clear the history of terminal rdp connections works on all versions of Windows XP, Vista, Windows 7, Windows 8 and Windows 10 and  server platforms like Windows Server 2003/2008/2012/2016.

How to clear the RDP connection history using a script

Above we have discussed how to clear the remote desktop history manually through the registry. However, doing it manually (especially on multiple computers) is time consuming. Therefore, we offer a small script (BAT file) that allows to automatically clear the history.

To automate the rdp history cleanup, you can put this script in the startup or to deploy it to computers by using a group policy.

1
2
3
4
5
6
7
@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"
cd %userprofile%\documents\
attrib Default.rdp -s -h
del Default.rdp

@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" cd %userprofile%\documents\ attrib Default.rdp -s -h del Default.rdp

Note. In some cases, the Documents folder can be moved from the standard directory c:\users\%username%\documents (for example, on another partition due to lack of space on the system drive).. In this case, you will have to change the path to the directory or manually find the file Default.rdp!

Let’s consider all the actions of the script:

  • Disable the output of the information to the console
  • Delete all the values in the registry key HKCU\Software\Microsoft\Terminal Server Client\Default (clear the list of recent rdp connections)
  • Delete the entire contents from HKCU\Software\Microsoft\Terminal Server Client\Servers (clears the rdp connection history and the saved user names)
  • Recreate the previously deleted registry key
  • Go to the directory with the Default.rdp file
  • Change the Default.rdp file attributes, by default it is Hidden and System
  • Delete the file Default.rdp file

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.

In case if you want to completely disable the history of remote desktop, you can try to prevent everyone from writing to these registry keys (but you should understand that this is an unsupported configuration).

Clearing cached 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 system Credential Manager. The next time you connect to the same computer, the RDP client automatically uses the previously saved password for authorization on the remote desktop.

mstsc can save rdp credentials

You can remove this 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.

delete saved rdp credentials

Alternatively, you can delete the 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 a domain environment, you can disable saving passwords for RDP connections by using the special policy Network access: Do not allow storage of passwords and credentials for network authentication (see an article).

 

2 comments
1
Facebook Twitter Google + Pinterest
previous post
Configure KMS server for MS Office 2016 Volume Activation
next post
Booting Windows 7 / 10 from GPT Disk on BIOS (non-UEFI) systems

Related Reading

Integrating Windows Updates into Windows 10 Install Image

February 12, 2019

Copying Large Files over an Unreliable Network Using...

February 11, 2019

“The update is not applicable to your computer”:...

February 10, 2019

Fix: Clock Reverts to Wrong Time After Computer...

February 8, 2019

Fix: BSOD Error 0x0000007B on Boot on Windows...

February 7, 2019

2 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

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange
  • Windows 10
  • Windows 8
  • Windows 7
  • Windows Server 2016
  • Windows Server 2012 R2
  • Windows Server 2008 R2
  • PowerShell
  • VMWare
  • MS Office

Recent Posts

  • ESXi: Slow Disk Performance on HPE Gen8

    February 15, 2019
  • Integrating Windows Updates into Windows 10 Install Image

    February 12, 2019
  • Copying Large Files over an Unreliable Network Using BITS and PowerShell

    February 11, 2019
  • Fix: Clock Reverts to Wrong Time After Computer (Server) Reboot

    February 8, 2019
  • Fix: BSOD Error 0x0000007B on Boot on Windows 7 and Server 2008 R2

    February 7, 2019
  • How to Disable Automatic Driver Updates in Windows 10?

    February 6, 2019
  • WSUS Windows Update Error 0x80244010: Exceeded max server round trips

    January 31, 2019
  • Configuring SSO (Single Sign-On) Authentication on Windows Server RDS

    January 29, 2019
  • Unable to Start or Connect to Virtual Disk Service in Disk Management

    January 28, 2019
  • How to Inject Drivers into a Windows 10 WIM/ISO Install Image?

    January 15, 2019
woshub.com

Follow us

  • Facebook
  • Twitter
  • RSS
Popular Posts
  • How to Repair Broken EFI Bootloader in Windows 10, 8.1
  • How to Allow Multiple RDP Sessions in Windows 10
  • Booting Windows 7 / 10 from GPT Disk on BIOS (non-UEFI) systems
  • Removable USB Flash Drive as Local HDD in Windows 10 / 7
  • How to Restore Deleted EFI Boot Partition in Windows 10/7
  • How to increase KMS current count (count is insufficient)
  • How to Download APPX Installation File from Microsoft Store in Windows 10 / 8.1
Footer Logo

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


Back To Top