Many sysadmins and developers face this frustrating scenario: You launch a critical batch process or database migration via Remote Desktop to a Windows Server 2003 machine, only to find your session terminated hours later due to inactivity. Unlike modern Windows versions where this is easily configurable, Server 2003 requires registry tweaks to solve.
The key solution lies in modifying these registry values on the target server (Windows Server 2003):
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\RemoteDesktop\Parameters]
"KeepAliveEnable"=dword:00000001
"KeepAliveInterval"=dword:00000001
"KeepAliveTimeout"=dword:000927c0
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server]
"KeepAliveEnable"=dword:00000001
The "KeepAliveTimeout"
value (0x927c0 = 600,000ms = 10 minutes) determines how often the server checks for active connections. Adjust this according to your needs.
For situations where you can't modify server settings, try these client-side tricks:
@echo off
:loop
timeout /t 300 >nul
echo %time% >> pinglog.txt
goto loop
Save this as a .bat file and run it in your RDP session to simulate activity every 5 minutes. Alternatively, use PowerShell:
while($true) {
[System.Windows.Forms.SendKeys]::SendWait("{SCROLLLOCK}")
Start-Sleep -Seconds 240
[System.Windows.Forms.SendKeys]::SendWait("{SCROLLLOCK}")
}
For domain environments, you can push these settings via GPO. Create a new GPO with these settings:
- Computer Configuration > Administrative Templates > Windows Components > Terminal Services > Sessions
- Set "Set time limit for active but idle Terminal Services sessions" to Enabled (0 = unlimited)
- Set "Set time limit for disconnected sessions" to Enabled (0 = unlimited)
Consider these specialized utilities when registry edits aren't possible:
- AutoIt scripts to simulate mouse movements
- RDP Session Keeper (commercial tool)
- TSCON command-line utility for session management
When running intensive batch processes or compilations through Remote Desktop (RDP) to Windows Server 2003, nothing's more frustrating than returning to find your session disconnected and processes terminated. The default configuration automatically logs off inactive sessions after a period (typically 10-15 minutes), which is particularly problematic for:
- Database migration scripts
- Machine learning training
- Automated testing suites
- Large-scale file operations
The most reliable solution involves modifying Group Policy on the Windows Server 2003 machine:
1. Open gpedit.msc
2. Navigate to:
Computer Configuration → Administrative Templates → Windows Components → Terminal Services → Sessions
3. Configure these policies:
- "Set time limit for disconnected sessions" → Not Configured
- "Set time limit for active but idle Terminal Services sessions" → Disabled
- "Set time limit for logoff of RemoteApp sessions" → Disabled
4. Run gpupdate /force
For situations where you don't have server admin rights, try these client-side tricks:
:: PowerShell keep-alive script
while($true) {
$wshell = New-Object -ComObject wscript.shell;
$wshell.SendKeys('{SCROLLLOCK}');
Start-Sleep -Seconds 60;
}
Or create a simple VBS script:
Set WshShell = WScript.CreateObject("WScript.Shell")
Do While True
WshShell.SendKeys "{SCROLLLOCK}"
WScript.Sleep(60000)
Loop
For permanent configuration without Group Policy:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TermService\Parameters]
"KeepAliveEnable"=dword:00000001
"KeepAliveInterval"=dword:00000001
"KeepAliveTimeout"=dword:000493e0
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services]
"MaxDisconnectionTime"=dword:00000000
"MaxIdleTime"=dword:00000000
When RDP proves too restrictive:
- Use PowerShell Remoting with
Enter-PSSession
- Configure SSH server (available via third-party tools on Server 2003)
- Create scheduled tasks that run under SYSTEM account
For critical operations, implement process monitoring:
$process = Start-Process -FilePath "your_long_running.exe" -PassThru
Register-ObjectEvent -InputObject $process -EventName Exited -Action {
Send-MailMessage -To "admin@domain.com" -Subject "Process completed" -Body "Your process has finished"
}