@echo off
set TOOLS=c:\tools

echo ####### %0 #######

%TOOLS%\RDPWInst.exe -i -s -r

echo installing custom inifile ...
if EXIST %TOOLS%\scripts\config\rdpwrap.ini (
  copy /Y %TOOLS%\scripts\config\rdpwrap.ini %Systemroot%\system32\rdpwrap.ini
)

echo forcing users to have only one RDP session ...
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TerminalServer" ^
  /v fSingleSessionPerUser /t REG_DWORD /d 1 /f

echo disabling disconnect of RDP sessions ...
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" ^
  /v MaxDisconnectionTime /t REG_DWORD /d 0 /f

echo disabling disconnect of IDLE sessions ...
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" ^
  /v MaxIdleTime /t REG_DWORD /d 0 /f

echo configuring cleanup for broken sessions ...
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" ^
  /v fResetBroken /t REG_DWORD /d 1 /f

echo ####### %0 #######