設定已斷線工作階段的時間限制 的登錄值 MaxDisconnectionTime (HKLM Terminal Services)電腦HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services

原則 ID
TS_SESSIONS_Disconnected_Timeout_2
適用範圍
電腦設定
支援的作業系統
至少需要 Windows Server 2003 作業系統或 Windows XP Professional
來源
Administrative Templates (.admx) for Windows 11 2026 Update (26H2) (版本 1.0)
類別
Windows 元件 › 遠端桌面服務 › 遠端桌面工作階段主機 › 工作階段時間限制

登錄

MaxDisconnectionTime

REG_SZ電腦
停用時的值
0
以 .reg · CMD · PowerShell 套用
已停用
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services]
"MaxDisconnectionTime"="0"
CMD · 已停用
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v "MaxDisconnectionTime" /t REG_SZ /d 0 /f
PowerShell · 已停用
New-Item -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -Force | Out-Null
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -Name 'MaxDisconnectionTime' -PropertyType String -Value '0' -Force | Out-Null

MaxDisconnectionTime

REG_DWORD電腦
啟用時的值
取決於選項值
元素
終止已中斷連線的工作階段
選項
項目儲存的值
永不0
1 分鐘60000
5 分鐘300000
10 分鐘600000
15 分鐘900000
30 分鐘1800000
1 小時3600000
2 小時7200000
3 小時10800000
6 小時21600000
8 小時28800000
12 小時43200000
16 小時57600000
18 小時64800000
1 天86400000
2 天172800000
3 天259200000
4 天345600000
5 天432000000
以 .reg · CMD · PowerShell 套用
.reg
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services]

; 選項 (只使用其中一個)
; 永不
"MaxDisconnectionTime"=dword:00000000
; 1 分鐘
"MaxDisconnectionTime"=dword:0000ea60
; 5 分鐘
"MaxDisconnectionTime"=dword:000493e0
; 10 分鐘
"MaxDisconnectionTime"=dword:000927c0
; 15 分鐘
"MaxDisconnectionTime"=dword:000dbba0
; 30 分鐘
"MaxDisconnectionTime"=dword:001b7740
; 1 小時
"MaxDisconnectionTime"=dword:0036ee80
; 2 小時
"MaxDisconnectionTime"=dword:006ddd00
; 3 小時
"MaxDisconnectionTime"=dword:00a4cb80
; 6 小時
"MaxDisconnectionTime"=dword:01499700
; 8 小時
"MaxDisconnectionTime"=dword:01b77400
; 12 小時
"MaxDisconnectionTime"=dword:02932e00
; 16 小時
"MaxDisconnectionTime"=dword:036ee800
; 18 小時
"MaxDisconnectionTime"=dword:03dcc500
; 1 天
"MaxDisconnectionTime"=dword:05265c00
; 2 天
"MaxDisconnectionTime"=dword:0a4cb800
; 3 天
"MaxDisconnectionTime"=dword:0f731400
; 4 天
"MaxDisconnectionTime"=dword:14997000
; 5 天
"MaxDisconnectionTime"=dword:19bfcc00
CMD
:: 選項 (只使用其中一個)

:: 永不
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v "MaxDisconnectionTime" /t REG_DWORD /d 0 /f
:: 1 分鐘
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v "MaxDisconnectionTime" /t REG_DWORD /d 60000 /f
:: 5 分鐘
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v "MaxDisconnectionTime" /t REG_DWORD /d 300000 /f
:: 10 分鐘
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v "MaxDisconnectionTime" /t REG_DWORD /d 600000 /f
:: 15 分鐘
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v "MaxDisconnectionTime" /t REG_DWORD /d 900000 /f
:: 30 分鐘
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v "MaxDisconnectionTime" /t REG_DWORD /d 1800000 /f
:: 1 小時
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v "MaxDisconnectionTime" /t REG_DWORD /d 3600000 /f
:: 2 小時
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v "MaxDisconnectionTime" /t REG_DWORD /d 7200000 /f
:: 3 小時
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v "MaxDisconnectionTime" /t REG_DWORD /d 10800000 /f
:: 6 小時
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v "MaxDisconnectionTime" /t REG_DWORD /d 21600000 /f
:: 8 小時
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v "MaxDisconnectionTime" /t REG_DWORD /d 28800000 /f
:: 12 小時
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v "MaxDisconnectionTime" /t REG_DWORD /d 43200000 /f
:: 16 小時
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v "MaxDisconnectionTime" /t REG_DWORD /d 57600000 /f
:: 18 小時
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v "MaxDisconnectionTime" /t REG_DWORD /d 64800000 /f
:: 1 天
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v "MaxDisconnectionTime" /t REG_DWORD /d 86400000 /f
:: 2 天
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v "MaxDisconnectionTime" /t REG_DWORD /d 172800000 /f
:: 3 天
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v "MaxDisconnectionTime" /t REG_DWORD /d 259200000 /f
:: 4 天
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v "MaxDisconnectionTime" /t REG_DWORD /d 345600000 /f
:: 5 天
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v "MaxDisconnectionTime" /t REG_DWORD /d 432000000 /f
PowerShell
# 共通: 建立機碼
New-Item -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -Force | Out-Null

# 選項 (只使用其中一個)
# 永不
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -Name 'MaxDisconnectionTime' -PropertyType DWord -Value 0 -Force | Out-Null
# 1 分鐘
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -Name 'MaxDisconnectionTime' -PropertyType DWord -Value 60000 -Force | Out-Null
# 5 分鐘
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -Name 'MaxDisconnectionTime' -PropertyType DWord -Value 300000 -Force | Out-Null
# 10 分鐘
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -Name 'MaxDisconnectionTime' -PropertyType DWord -Value 600000 -Force | Out-Null
# 15 分鐘
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -Name 'MaxDisconnectionTime' -PropertyType DWord -Value 900000 -Force | Out-Null
# 30 分鐘
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -Name 'MaxDisconnectionTime' -PropertyType DWord -Value 1800000 -Force | Out-Null
# 1 小時
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -Name 'MaxDisconnectionTime' -PropertyType DWord -Value 3600000 -Force | Out-Null
# 2 小時
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -Name 'MaxDisconnectionTime' -PropertyType DWord -Value 7200000 -Force | Out-Null
# 3 小時
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -Name 'MaxDisconnectionTime' -PropertyType DWord -Value 10800000 -Force | Out-Null
# 6 小時
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -Name 'MaxDisconnectionTime' -PropertyType DWord -Value 21600000 -Force | Out-Null
# 8 小時
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -Name 'MaxDisconnectionTime' -PropertyType DWord -Value 28800000 -Force | Out-Null
# 12 小時
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -Name 'MaxDisconnectionTime' -PropertyType DWord -Value 43200000 -Force | Out-Null
# 16 小時
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -Name 'MaxDisconnectionTime' -PropertyType DWord -Value 57600000 -Force | Out-Null
# 18 小時
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -Name 'MaxDisconnectionTime' -PropertyType DWord -Value 64800000 -Force | Out-Null
# 1 天
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -Name 'MaxDisconnectionTime' -PropertyType DWord -Value 86400000 -Force | Out-Null
# 2 天
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -Name 'MaxDisconnectionTime' -PropertyType DWord -Value 172800000 -Force | Out-Null
# 3 天
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -Name 'MaxDisconnectionTime' -PropertyType DWord -Value 259200000 -Force | Out-Null
# 4 天
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -Name 'MaxDisconnectionTime' -PropertyType DWord -Value 345600000 -Force | Out-Null
# 5 天
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -Name 'MaxDisconnectionTime' -PropertyType DWord -Value 432000000 -Force | Out-Null