Set action to take when logon hours expire: registry value LogonHoursActionUserHKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System

Policy ID
LogonHoursPolicyDescription
Scope
User Configuration
Supported on
At least Windows Vista
Source
Administrative Templates (.admx) for Windows 11 2026 Update (26H2) (version 1.0)
Category
Windows Components › Windows Logon Options

Registry

LogonHoursAction

REG_DWORDUser
Enabled value
Depends on the option value
Element
Set action to take when logon hours expire
Options
ItemStored value
Lock1
Disconnect2
Logoff3
Apply with .reg · CMD · PowerShell
.reg
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System]

; Options (use only one)
; Lock
"LogonHoursAction"=dword:00000001
; Disconnect
"LogonHoursAction"=dword:00000002
; Logoff
"LogonHoursAction"=dword:00000003
CMD
:: Options (use only one)

:: Lock
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System" /v "LogonHoursAction" /t REG_DWORD /d 1 /f
:: Disconnect
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System" /v "LogonHoursAction" /t REG_DWORD /d 2 /f
:: Logoff
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System" /v "LogonHoursAction" /t REG_DWORD /d 3 /f
PowerShell
# Common: create the key
New-Item -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\System' -Force | Out-Null

# Options (use only one)
# Lock
New-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\System' -Name 'LogonHoursAction' -PropertyType DWord -Value 1 -Force | Out-Null
# Disconnect
New-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\System' -Name 'LogonHoursAction' -PropertyType DWord -Value 2 -Force | Out-Null
# Logoff
New-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\System' -Name 'LogonHoursAction' -PropertyType DWord -Value 3 -Force | Out-Null