You are here

Remote Desktop Portable Launcher and Cleanup Utility

11 posts / 0 new
Last post
vertigo_2_20
Offline
Last seen: 16 years 3 weeks ago
Joined: 2008-03-03 20:27
Remote Desktop Portable Launcher and Cleanup Utility

Since there are lots of people out there, myself included, who don't like using Remote Desktop on public computers because it leaves information behind, which is a hassle to clean up after, I wrote a small batch file for this purpose. This isn't a portable app in the sense of being its own program or even allowing you to run remote desktop on a computer that doesn't have it, but for computers that do, it should be a lot better than having to go through and clean up the tracks MS leaves behind or avoiding the use of it altogether on a public computer because of them. And if you use the same public computer on a regular basis, you could even stick it on the local drive so you don't need your thumb drive to use it. It's quite possible it could be coded more eloquently or even in another language, but my programming skills are pretty basic and it works, so it's not worth the time making it better. However, please let me know if there's anything that is just outright bad programming. Here's the code:

@echo off

: runs the Remote Desktop Client (comment out by changing to :mstsc if you want this program to only clean up after Remote Desktop usage, but not actually run the RDC)

mstsc
:: add /v:xx.xxx.xxx.xx[:yyyy] after "mstsc" where the x's are the IP of the computer you want to connect to and the y's are the [optional] port

: clears the Remote Desktop information from the registry and reports if successful (if no report is received, this step failed)

reg delete "HKCU\Software\Microsoft\Terminal Server Client" /f
reg query "HKCU\Software\Microsoft\Terminal Server Client" /v MRU0 || cls && echo. && echo Registry cleaned successfully!

echo.

: deletes the default.rdp file from the my documents folder and reports if successful or not

if exist c:\docume~1\%username%\mydocu~1\default.rdp del /ah c:\docume~1\%username%\mydocu~1\default.rdp

echo.

if exist c:\docume~1\%username%\mydocu~1\default.rdp echo %userprofile%\Default.rdp deletion FAILED!!!!!
if not exist c:\docume~1\%username%\mydocu~1\default.rdp echo %userprofile%\Default.rdp deletion successful!

: waits ~8 seconds (8000 ms) before closing the window to allow for visual confirmation of success or failure in cleanup (window can be closed manually)

ping 1.1.1.1 -n 1 -w 8000 > nul

Riax
Riax's picture
Offline
Last seen: 8 years 11 months ago
Joined: 2007-09-06 14:41
A few things...

Firstly, you should know that by using RDC on a trusted machine to save your connection preferences for a specific host to Whatever.rdp (Just click Save or Save As on the General tab), you can create a better, more efficient way of doing this. Not only does it accomplish everything your batch file does, it lets you configure connection features (such as local resource access). I recommend that you do not save your RDC password in the RDP file, as it is an ASCII file which can be opened in any text editor. Though, common sense should have told you not to do this in the first place. When you run an RDP file directly by double-clicking on it, no information is remembered by the host machine; your preferences are loaded once to preconfigure the connection and are forgotten the moment you disconnect your session. Depending on the host machine's audit policy, your session open and close times may be recorded in the event log on the host machine, but this is something that would happen using your batch file anyway.

Secondly, commenting lines in a batch file is not done with colons. Colons are used to create labels for use with goto commands. Each time you used a colon to comment a line, you were actually creating a label. The correct way to create a comment (or rather, "remark") in a batch file is to prefix the line with "REM ". For example:

REM This is a remark. It will be ignored by the command interpreter.

Last, the two IF statements near the end of the batch file seem to be missing the echo command (i.e. "if [...] echo deletion successful!").

Sorry if I seem to be bumping this.

Her song leaves the other side in flight for their lives now;
They are not long for the world.
No one leaves; line up for inevitable wipeout.
All you've done - now it's what you deserve.
Machinae Supremacy ~ Laser Speed Force

BuddhaChu
BuddhaChu's picture
Offline
Last seen: 7 years 6 months ago
Joined: 2006-11-18 10:26
REM vs ::

REM may be the "most correct" way to do commenting in DOS/Windows batch files, but double colons (::) are used a LOT in examples on the internet so I'd call them an acceptable alternative.

Cancer Survivors -- Remember the fight, celebrate the victory!
Help control the rugrat population -- have yourself spayed or neutered!

Riax
Riax's picture
Offline
Last seen: 8 years 11 months ago
Joined: 2007-09-06 14:41
Yes, a double-colon

Yes, a double-colon preceding a line would be acceptable, but notice that only one of his five comments actually uses a double-colon.

Her song leaves the other side in flight for their lives now;
They are not long for the world.
No one leaves; line up for inevitable wipeout.
All you've done - now it's what you deserve.
Machinae Supremacy ~ Laser Speed Force

BuddhaChu
BuddhaChu's picture
Offline
Last seen: 7 years 6 months ago
Joined: 2006-11-18 10:26
Ah yes, I see that now...

I sit corrected. Wink

Four labels and one actual comment.

Cancer Survivors -- Remember the fight, celebrate the victory!
Help control the rugrat population -- have yourself spayed or neutered!

Patrick Patience
Offline
Last seen: 4 years 4 months ago
DeveloperModerator
Joined: 2007-02-20 19:26
Lol

I sit corrected. Wink

Well somebody had to laugh.

Riax
Riax's picture
Offline
Last seen: 8 years 11 months ago
Joined: 2007-09-06 14:41
I admit, I chuckled a bit.

I admit, I chuckled a bit. Blum

Her song leaves the other side in flight for their lives now;
They are not long for the world.
No one leaves; line up for inevitable wipeout.
All you've done - now it's what you deserve.
Machinae Supremacy ~ Laser Speed Force

vertigo_2_20
Offline
Last seen: 16 years 3 weeks ago
Joined: 2008-03-03 20:27
remarks

I personally don't like using REM, just think it clutters things. You are correct though that they should be double colons. As for the if statements at the end, they do both contain an echo command.

With saving and then running and rdp file, it does retain the ip which shows up the next time remote desktop is run. Either way, I did this just as much for the fun of coding it as for the actual use of it. And if even one person besides myself finds it useful, then it was worth doing.

Riax
Riax's picture
Offline
Last seen: 8 years 11 months ago
Joined: 2007-09-06 14:41
I could have sworn those

I could have sworn those weren't there. My eyesight must be going.

I just tried to duplicate this, but couldn't. I copied an existing RDP file and changed the "full address" line to my server's LAN IP address. I have never before connected that way, and it didn't show up in RDC when I opened it from the Start menu. Pardon I'm running Vista Business SP1 (all available updates installed) and Server 2003 Standard SP2 (ditto).

Her song leaves the other side in flight for their lives now;
They are not long for the world.
No one leaves; line up for inevitable wipeout.
All you've done - now it's what you deserve.
Machinae Supremacy ~ Laser Speed Force

vertigo_2_20
Offline
Last seen: 16 years 3 weeks ago
Joined: 2008-03-03 20:27
xp

I'm running XP SP2 (at home, at work, and on the school computers I use ocassionally). Based off of what you said about copying over an existing rdp file, I created one and saved it, removed the registry information and the default file from my documents, then ran the rdp file, but it still saved the info. Maybe Vista is just better about that, since they went all out on security. I don't know anything about Server 03, but I suppose it's possible that has higher security as well.

charliedukeds
Offline
Last seen: 15 years 4 months ago
Joined: 2008-12-08 12:01
Public Mode

If you just call mstsc.exe with the /public switch, it stops it from saving information locally.

Log in or register to post comments