How to Disable Automatic Session Logoff/Lock on Windows Server 2012 R2 Standalone Installation


3 views

When administering a standalone Windows Server 2012 R2 (non-domain joined), you might encounter the system automatically logging off or locking the session after periods of inactivity. This behavior persists even without Group Policy configuration, as certain local security policies are enabled by default.

The automatic logoff behavior is controlled by two primary settings:

1. Screen saver timeout (with password protection)
2. Interactive logon timeout settings

For persistent configuration that survives reboots:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters]
"autodisconnect"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Power]
"PromptPasswordOnResume"=dword:00000000

For administrators preferring scripted solutions:

# Disable screen saver timeout
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name ScreenSaveTimeOut -Value 0

# Disable screen saver password protection
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name ScreenSaverIsSecure -Value 0

# Prevent session disconnection
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" -Name autodisconnect -Value 0

# Optional: Disable lock screen timeout
powercfg -change -standby-timeout-ac 0
powercfg -change -monitor-timeout-ac 0

After applying changes, verify the configuration:

# Check screen saver settings
Get-ItemProperty -Path "HKCU:\Control Panel\Desktop" | Select-Object ScreenSaveTimeOut, ScreenSaverIsSecure

# Verify server service settings
Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" | Select-Object autodisconnect

For those preferring the graphical interface:

  1. Open "Local Group Policy Editor" (gpedit.msc)
  2. Navigate to: Computer Configuration → Administrative Templates → System → Power Management
  3. Disable "Prompt for password on resume from hibernate/suspend"
  4. Navigate to: User Configuration → Administrative Templates → Control Panel → Personalization
  5. Set "Password protect the screen saver" to Disabled

Remember that disabling automatic logoff affects security. Consider implementing these alternatives:

  • Configure RDP session timeouts instead of local console
  • Use third-party tools like AutoHotkey to simulate activity
  • Implement scheduled tasks to periodically reset idle timers

For standalone Windows Server 2012 R2 systems, the automatic logoff behavior is controlled through Local Security Policy. Here's the step-by-step procedure:


1. Press Win+R, type secpol.msc and press Enter
2. Navigate to: Local Policies → Security Options
3. Find these two policies:
   - "Interactive logon: Machine inactivity limit"
   - "Microsoft network server: Amount of idle time..."
4. Set both values to "0" (which means never log off)

If you prefer registry edits or need to script the solution for multiple servers:


Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters]
"autodisconnect"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"InactivityTimeoutSecs"=dword:00000000

Save this as a .reg file and double-click to apply, or deploy via Group Policy if later joined to a domain.

For administrators managing multiple standalone servers, here's a PowerShell script to implement the changes:


# Disable inactivity timeout
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" 
    -Name "InactivityTimeoutSecs" -Value 0 -Type DWord

# Disable SMB autodisconnect
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" 
    -Name "autodisconnect" -Value 0 -Type DWord

# Optional: Verify changes
Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" | 
    Select-Object InactivityTimeoutSecs
Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" | 
    Select-Object autodisconnect

Even after making these changes, check the screensaver settings:


# Check current screensaver timeout (seconds)
(Get-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name ScreenSaveTimeOut).ScreenSaveTimeOut

# Disable screensaver timeout
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name ScreenSaveTimeOut -Value 0

Verify these related settings to ensure complete session persistence:

  • Power Options → Turn off display: Never
  • Power Options → Put computer to sleep: Never
  • Remote Desktop Session Host Configuration → Set time limits to "Never"