




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
sCmd := Format(‘%s\system32\mstsc.exe “%s” /w:%d /h:%d %s %s’,
[WinDir, ParamStr(2), ScrWidth, ScrHeight, ParamStr(1), ParamStr(3)]);
else begin
[WinDir, ParamStr(1), ScrWidth, ScrHeight, ParamStr(2), ParamStr(3)]);

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


You can find the Tool and .reg file in this download: RDPWithLocalTaskbar (3200 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


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