Users logs out every 24 hours of login

Anonymous
2024-12-12T16:00:58+00:00

Hello,

I have Windows Server 2022 on Azure. I log into that server via the remote desktop manager, but if I do not log in before the period, the user account gets logged out after 24 hours. Once I log in, it will take that as a reference time for the next logout session after 24 hours.

For example, let's say I log in today at 9 AM and do my work and just close the remote desktop leaving the user account logged in, so after the next day the user account will be signed out at 9 AM if I did not log in before that. And considering that I log in before let's say at 2 am, then it will sign out on the next day at 2 am.

The reason I want to keep the user account all the time is that there are a lot of jobs that are scheduled to run during the day.

I have tried editing the group policy, and registry, also it is not about no moment or live action on the server, because I am using a mouse giggler on it. Probably it is more about some setting for remote connection. I would appreciate it if someone could chime over here.

Windows for business | Windows Server | User experience | Remote desktop services and terminal services

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question. To protect privacy, user profiles for migrated questions are anonymized.

0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Anonymous
    2024-12-12T21:55:35+00:00

    Hello,

    I have Windows Server 2022 on Azure. I log into that server via the remote desktop manager, but if I do not log in before the period, the user account gets logged out after 24 hours. Once I log in, it will take that as a reference time for the next logout session after 24 hours.

    For example, let's say I log in today at 9 AM and do my work and just close the remote desktop leaving the user account logged in, so after the next day the user account will be signed out at 9 AM if I did not log in before that. And considering that I log in before let's say at 2 am, then it will sign out on the next day at 2 am.

    The reason I want to keep the user account all the time is that there are a lot of jobs that are scheduled to run during the day.

    I have tried editing the group policy, and registry, also it is not about no moment or live action on the server, because I am using a mouse giggler on it. Probably it is more about some setting for remote connection. I would appreciate it if someone could chime over here.

    To prevent your Windows Server 2022 user account from being logged out after 24 hours on Azure, you need to address session timeout policies and settings that are likely causing this behavior.

    The behavior you are experiencing is likely due to session timeout policies configured either at the operating system level or within Azure’s environment. These policies are designed to log off inactive or idle sessions for security and resource management purposes. However, in your case, it seems tied to a specific time period (24 hours) rather than inactivity.

    Modify Local Group Policy Settings

    Press Win + R, type gpedit.msc, and press Enter.

    Navigate to the following path: Computer Configuration > Administrative Templates > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Session Time Limits

    Adjust the following settings:

    1. Set time limit for active but idle Remote Desktop Services sessions: Set this to “Disabled” or configure it with a longer duration (e.g., 7 days).
    2. Set time limit for disconnected sessions: Set this to “Never”.
    3. End session when time limits are reached: Set this to “Disabled”.

    Apply the changes by clicking OK and then close the Group Policy Editor.

    Force a policy update by running the following command in an elevated Command Prompt: gpupdate /force

    Restart your server or log off and back in for changes to take effect.

    Check Registry Settings

    If Group Policy changes do not resolve the issue, verify and modify registry keys related to session limits:

    Steps

    1. Open the Registry Editor (regedit):
      • Press Win + R, type regedit, and press Enter.
    2. Navigate to the following key:
       HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server
      
    3. Look for these values (create them if they don’t exist) and set them as follows:
      • IdleTimeout: Set this DWORD value to 0 (disables idle timeout).
          Path: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server
          Value Name: IdleTimeout
          Value Type: REG_DWORD
          Value Data: 0
        
      • MaxDisconnectionTime: Set this DWORD value to 0 (prevents disconnection due to inactivity).
          Path: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server
          Value Name: MaxDisconnectionTime
          Value Type: REG_DWORD
          Value Data: 0
        
    4. Restart your server after making these changes.

    Verify Azure-Specific Timeout Policies

    Azure environments may impose additional restrictions on session durations through its platform-level configurations:

    Steps

    1. Log into your Azure portal.
    2. Check if there are any policies applied at the subscription or resource group level that enforce session timeouts.
    3. Specifically review settings under:
      • Azure Virtual Machine Scale Sets.
      • Azure Bastion Host (if used).
    4. If applicable, adjust these policies or consult with your Azure administrator.

    Disable Automatic Logout via Task Scheduler

    If none of the above resolves your issue, you can create a task in Task Scheduler that prevents automatic logout by periodically resetting session timers:

    Steps:

    1. Open Task Scheduler (taskschd.msc).
    2. Create a new task with these configurations:
      • Trigger: Every hour (or less frequent depending on preference).
      • Action: Run a simple script like moving the mouse cursor slightly or sending a keystroke using PowerShell.
    3. Example PowerShell script for keeping sessions alive:
       Add-Type -TypeDefinition @"
           using System;
           using System.Runtime.InteropServices;
           public class MouseMover {
               [DllImport("user32.dll")]
               public static extern bool SetCursorPos(int X, int Y);
           }
       "@
           [MouseMover]::SetCursorPos(100,100)
           Start-Sleep -Seconds 5
           [MouseMover]::SetCursorPos(200,200)
      
    0 comments No comments
  2. Anonymous
    2024-12-19T08:53:40+00:00

    Hello,

    Thank you for posting in the Microsoft Community forum.

    I understand that your question is related to Azure. Given the technical nature of your inquiry, I recommend redirecting your question to our specialized forum dedicated to this topic:

    Azure - Microsoft Q&A

    This platform hosts experts who can provide detailed guidance tailored to your situation, ensuring a more precise and effective solution.

    Thank you for your understanding and cooperation.

    Best regards

    Jacen

    0 comments No comments