INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Keep Remote Desktop Session alive / preven RDP timeout

Keep Remote Desktop Session alive / preven RDP timeout

(OP)
Long story short, I have a small Access application started on a Remote Desktop Connection that reads data on the client side of the connection and puts it in a table on the server side and the server (Windows 2008 R2) is domainless with all users set to timeout after an hour of inactivity which as I understand it makes it impossible to configure a different user timeout.

In short I really need to prevent the timeout in code. The code that is running is running on in the timer event of a startup form. I thought I had a sendkeys command keeping the session alive but alas I think I must have done something stupid like test with an admin account that does not timeout.

I am off to dig on the internet... with a cold...

RE: Keep Remote Desktop Session alive / preven RDP timeout

(OP)
I did not use all the code but kept it in case it would prove useful later.

Reportedly calling MouseJiggle defined below seems to keep the session alive... On the other hand, it also reportedly stopped working after an hour so I need to play some more to find out for sure.

CODE

Option Compare Database
Option Explicit

'Digested from http://wellsr.com/vba/2015/excel/vba-mouse-move-and-mouse-click-macro/

'Declare mouse events

'SetCursorPos sets the mouse position relative to the top left corner which is 0,0 in pixels.
#If Win64 Then
Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
#Else
Public Declare PtrSafe Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As LongPtr
#End If

#If Win64 Then
Public Declare PtrSafe Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
#Else
Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
#End If

Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const MOUSEEVENTF_RIGHTDOWN As Long = &H8
Public Const MOUSEEVENTF_RIGHTUP As Long = &H10
'Declare sleep
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Public Sub LeftClick()
    'Left click is pushing the left mouse button down and releasing it by using up
    mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 'Push down
    Sleep 50 '50 millisecond pause
    mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0   'Release
End Sub

Public Sub RightClick()
    'Right click is pushing the Right mouse button down and releasing it by using up
    mouse_event MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0 'Push down
    Sleep 50 '50 millisecond pause
    mouse_event MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0 'Release
End Sub

Public Sub MouseJiggle()
    SetCursorPos 0, 0
    Sleep 50
    SetCursorPos 10, 0
    Sleep 50
    SetCursorPos 10, 10
    Sleep 50
    SetCursorPos 0, 10
End Sub 

RE: Keep Remote Desktop Session alive / preven RDP timeout

>calling MouseJiggle defined below seems to keep the session alive

I'd be surprised, to be honest

RE: Keep Remote Desktop Session alive / preven RDP timeout

(OP)
That does not seem to fix it when I test personally...

I did create the below key and set it to 2. That should allow the session to allow active for such automated updates.

HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\RemoteDesktop_SuppressWhenMinimized
REG_DWORD

Anyone have the silver bullet for this one or at least some other though on simulated input that may help?

RE: Keep Remote Desktop Session alive / preven RDP timeout

(OP)
No fixes...

Additional reading suggests that the only solution may involve sending input to the Remote Desktop Application on the client machine.

When I ask someone with more experience in such things than me, I got the answer give up.

So unless someone has a great idea, I am calling it. I think the only real solution that has merit is on the server side and involves adding a domain controller to the mix in order to support group policy so timeouts are not a global setting. I only mention this as the possible alternative to a code solution.

RE: Keep Remote Desktop Session alive / preven RDP timeout

> may involve sending input to the Remote Desktop Application

Doesn't seem to work. The input idle does not seem to be how RDP times things

RE: Keep Remote Desktop Session alive / preven RDP timeout

(OP)
On the one hand I think, good job Microsoft that is secure. On the other hand I think, shame on you Microsoft requiring a domain to configure this for different users/groups. But other reading I have done suggest standalone RDS has gone the way of the Dodo in versions past Win Server 2008 R2... I smell license fees.

Of course I am assuming the server can't handle AD too... On the other hand; if it doesn't work, there really is not an alternative other than adding hardware / hosted VM to the mix.

Failing the Access workaround, that is probably far enough off topic to go.

Thanks for having a look at the Remote Desktop Application.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close