JSI Tip 9087. How can I make Remote Desktop Connection forget a previously connected computer?

Jerold Schulman

February 22, 2005

1 Min Read
ITPro Today logo in a gray background | ITPro Today

When you use Windows XP's Remote Desktop Connection client, the computers that you connected to are remembered in an MRUn Value Name at HKEY_CURRENT_USERSoftwareMicrosoftTerminal Server ClientDefault.

When you connect to a computer, the new connection is named MRU0 and other value names are moved down sequentially.

I have scripted RDCForget.bat to remove one or more entries from the MRUn list, so they do NOT appear in the Computer box.

The syntax for using RDCForget.bat is:

RDCForget V|A|Computer1 [Computer2 ... ComputerN]

Where:

V          indicates that you want to view the list of saved computers.A          indicates that you want to delete the entire list of saved computers.ComputerX  indicates that you want to delete this specific computer name, or IP address, or leading portion thereof:           192.168.0. would delete all computer whose IP address starts with 192.168.0..           JSI would delete all computer whose name starts with JSI.

RDCForget.bat contains:

@echo offsetlocalif {%1}
{} goto syntaxset action=%1set action=%action:"=%if /i "%action%" EQU "V" set action=V&goto OKif /i "%action%" EQU "A" set action=Agoto OK:syntax@echo Syntax: RDCForget V^|A^|Computer1 [Computer2 ... ComputerN]endlocalgoto :EOF:OKset key="HKCUSoftwareMicrosoftTerminal Server ClientDefault"set fnd1=FIND "MRU"set fnd2=FIND "REG_SZ":OK1for /f "Tokens=1,2*" %%a in ('reg query %key%^|%fnd1%^|%fnd2%') do ( set MRUx=%%a set MRUd=%%c call :doit)shiftif {%1}
{} endlocal&goto :EOFset action=%1set action=%action:"=%if /i "%action%" EQU "A" goto syntaxgoto OK1:doitif "%action%" EQU "V" call :regv&goto :EOFif "%action%" EQU "A" call :regdel %MRUx%&goto :EOFfor /f "Tokens=*" %%x in ('@echo %MRUd%^|Findstr /I /B /L /C:"%action%"') do ( call :regdel %MRUx%)goto :EOF:regdelset wrk1=%MRUx%    #set wrk2=%wrk1:~0,8%@echo Delete %wrk2% %MRUd%reg delete %key% /V %1 /[email protected] :EOF:regvset wrk1=%MRUx%    #set wrk2=%wrk1:~0,8%@echo %wrk2% %MRUd%



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like