Delete Remote Connection Records and Run Box Records – Batch File Windows 11 as Example

@echo off

REM Delete remote desktop connection history in registry

reg delete HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Default /va /f

reg delete HKEY_LOCAL_MACHINE\Software\Microsoft\Terminal Server Client\Default /va /f

reg delete HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Servers /f

REM Add registry key

reg add HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Servers

REM Delete Default.rdp file in Documents folder

del /ah %homepath%\documents\default.rdp

REM Delete run box history

reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU /va /f

del /Q /F %APPDATA%\Microsoft\Windows\Recent\*

echo.

%APPDATA%\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt

REM Delete contents of a certain folder

@echo off

set folderPath=C:\123\123

if exist %folderPath% (

rmdir /s /q %folderPath%

echo folder ok

) else (

echo folder none

)

REM Delete contents of a certain folder

@echo off

set folderPath=C:\Users\Administrator\AppData\Local\Microsoft\Terminal Server Client

if exist %folderPath% (

rmdir /s /q %folderPath%

echo folder ok

) else (

echo folder none

)

REM Delete Clear system events

PowerShell -ExecutionPolicy Bypass -File C:\Users\Administrator\Desktop\ClearEventLogs.ps1

echo all ok

pause