Fix RDP Auto-Lock & Account Lockout Forever
Windows RDP Guide

Fix RDP Account Lockout
& Auto-Lock Forever

Every time you spin up a new RDP or VPS, the same problems appear — account locks after a few wrong passwords, session disconnects on idle, screen locks itself. This guide permanently fixes all of it with a single PowerShell script you run once.

01 — The Problem

What Goes Wrong on a Fresh RDP

When you connect to a new Windows VPS via Remote Desktop, three things will eventually frustrate you — sometimes within the first hour.

Account Locked Out "As a security precaution, the user account has been locked because there were too many logon attempts or password change attempts. Wait a while before trying again, or contact your system administrator."
Account Lockout
Too many failed login attempts locks your Administrator account. Default threshold is only 3–5 attempts on most servers.
Session Timeout
RDP disconnects you after idle time. This silently kills running scripts, bots, and long-running processes.
Auto Sleep / Lock
Screen locks or the machine sleeps, breaking your remote connection and requiring a physical or console reset.
02 — The Solution

One Script. Run Once. Fixed Forever.

Instead of navigating Group Policy, Registry Editor, and Power Settings separately — paste this single PowerShell script and you are done. Everything is handled in one execution.

Prerequisite: PowerShell must be opened as Administrator. Press Win + R, type powershell, then hit Ctrl + Shift + Enter. Without admin rights, registry writes will silently fail.
03 — The Script

Complete PowerShell Script

PowerShell
# Run as Administrator
Write-Host "Setting up RDP — No Lockout, No Timeout..." -ForegroundColor Green

# ===== ACCOUNT LOCKOUT DISABLE =====
net accounts /lockoutthreshold:0

# Disable machine inactivity auto lock
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" `
  /v InactivityTimeoutSecs /t REG_DWORD /d 0 /f

# Disable RDP idle session timeout
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" `
  /v MaxIdleTime /t REG_DWORD /d 0 /f

# Disable disconnected session timeout
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" `
  /v MaxDisconnectionTime /t REG_DWORD /d 0 /f

# Disable active session limit
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" `
  /v MaxConnectionTime /t REG_DWORD /d 0 /f

# Prevent session ending on timeout
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" `
  /v fResetBroken /t REG_DWORD /d 0 /f

# Disable screen saver lock
reg add "HKCU\Control Panel\Desktop" `
  /v ScreenSaveActive /t REG_SZ /d 0 /f
reg add "HKCU\Control Panel\Desktop" `
  /v ScreenSaverIsSecure /t REG_SZ /d 0 /f

# Set power settings to never sleep
powercfg /change monitor-timeout-ac 0
powercfg /change standby-timeout-ac 0
powercfg /change hibernate-timeout-ac 0

# Apply group policy changes
gpupdate /force

Write-Host "DONE! Restart your VPS/RDP once." -ForegroundColor Cyan
04 — How To Run

Step-by-Step Instructions

  1. Open PowerShell as Administrator — Press Win + R, type powershell, then Ctrl + Shift + Enter

  2. Copy the script — Click the "Copy" button in the code block above

  3. Paste into PowerShell — Right-click inside the window — it pastes automatically

  4. Press Enter — Wait for the "DONE!" confirmation message

  5. Restart once — All settings apply permanently after one reboot

05 — Reference

What Each Command Does

Command What It Fixes Status
net accounts /lockoutthreshold:0 Disables account lockout — no limit on failed login attempts ever Active
InactivityTimeoutSecs = 0 Machine never locks due to inactivity at OS level Active
MaxIdleTime = 0 RDP session never disconnects when idle Active
MaxDisconnectionTime = 0 Disconnected sessions are kept alive indefinitely Active
ScreenSaveActive = 0 Screensaver and its password lock disabled Active
powercfg / 0 Monitor, standby & hibernate all set to Never on AC power Active
gpupdate /force Forces all Group Policy changes to apply immediately Active

Run Once — Fixed Forever

After this script and one restart, your RDP will never auto-lock, timeout, or lock your account again. Perfect for 24/7 VPS bots, automation scripts, and always-on servers.