I usually have lots of Terminal Server sessions open when I’m working, both direct sessions but also “sessions in sessions”. In order to keep overview on my desktop I prefer to make the session size as big as possible without being full screen (so keep my local taskbar visible).

LocalTaskBar2

If I run a session in a session I do this again, this makes switching sessions very easy and you can always see which session you are in:

LocalTaskBar3

In order to specify the desktop size to mstsc we have to know the height of the taskbar and subtract this from the height of the desktop. Because the taskbar can be made bigger or it’s size can be different when a theme (such as Vista’s AERO is used) I wrote a little tool that calculates the correct desktop size and kicks off the session. I used the SystemParametersInfo and GetSystemMetrics API’s:

SystemParametersInfo(SPI_GETWORKAREA, 0, @Rect, 0)

// Width = Screen Width
ScrWidth := Rect.Right – Rect.Left;
// Height = Maximum client area height
ScrHeight := GetSystemMetrics(SM_CYFULLSCREEN);

Next I run mstsc specifying the width and height and the rdp file as given by commandline:

if (UpperCase(ParamStr(1)) = ‘/CONSOLE’) or (UpperCase(ParamStr(1)) = ‘/ADMIN’) then
begin
sCmd := Format(‘%s\system32\mstsc.exe “%s” /w:%d /h:%d %s %s’,
[WinDir, ParamStr(2), ScrWidth, ScrHeight, ParamStr(1), ParamStr(3)]);
end
else begin
sCmd := Format(‘%s\system32\mstsc.exe “%s” /w:%d /h:%d %s %s’,
[WinDir, ParamStr(1), ScrWidth, ScrHeight, ParamStr(2), ParamStr(3)]);
end;

Finally I add my tool to the registry so it appears in the context menu of RDP Files.

Menu

You can find the Tool and .reg file in this download: RDPWithLocalTaskbar (4936 downloads )

PS the reg file was made for the v6 version of the MSTSC client where the /console switch was replaced /admin. If you have an older version you need to modify HKEY_CLASSES_ROOT\RDP.File\shell\connectconsole\command

“%systemroot%\system32\RDPWithLocalTaskbar.exe” “%1” /admin

to

“%systemroot%\system32\RDPWithLocalTaskbar.exe” “%1” /console