Skip navigation

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

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_USER\Software\Microsoft\Terminal Server Client\Default.

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 off
setlocal
if \{%1\}

\{\} goto syntax set action=%1 set action=%action:"=% if /i "%action%" EQU "V" set action=V&goto OK if /i "%action%" EQU "A" set action=A goto OK :syntax @echo Syntax: RDCForget V^|A^|Computer1 \[Computer2 ... ComputerN\] endlocal goto :EOF :OK set key="HKCU\Software\Microsoft\Terminal Server Client\Default" set fnd1=FIND "MRU" set fnd2=FIND "REG_SZ" :OK1 for /f "Tokens=1,2*" %%a in ('reg query %key%^|%fnd1%^|%fnd2%') do ( set MRUx=%%a set MRUd=%%c call :doit ) shift if \{%1\}

\{\} endlocal&goto :EOF set action=%1 set action=%action:"=% if /i "%action%" EQU "A" goto syntax goto OK1 :doit if "%action%" EQU "V" call :regv&goto :EOF if "%action%" EQU "A" call :regdel %MRUx%&goto :EOF for /f "Tokens=*" %%x in ('@echo %MRUd%^|Findstr /I /B /L /C:"%action%"') do ( call :regdel %MRUx% ) goto :EOF :regdel set wrk1=%MRUx% # set wrk2=%wrk1:~0,8% @echo Delete %wrk2% %MRUd% reg delete %key% /V %1 /F @echo. goto :EOF :regv set wrk1=%MRUx% # set wrk2=%wrk1:~0,8% @echo %wrk2% %MRUd%



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish