Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can the GUI of an RDP session remain active after disconnect

I'm running automated testing procedures that emulates keystrokes and mouseclicks 24/7.

Although it runs fine locally, on an RDP session it stops running once minimized or disconnected. Apparently, the GUI doesn't exist if you can't physically see it on the screen.

There is a registry work-around for keeping the GUI active for minimizing the window, but I know of no way to keep it alive after disconnect.

Ideally, I would have this run on the server Windows console session which would not care about being disconnected but in a hosted environment (I tried Amazon and Go Daddy) there is no way to access the console session.

Does anyone know how I can get around this? Basically any solution that allows me to run my application on a VPS. I need the reliability of a host but the flexibility to run it as if I was sitting right in front.

like image 822
user2029890 Avatar asked Apr 08 '13 19:04

user2029890


People also ask

What happens when you close RDP session?

Any applications running within the session will be closed. Unsaved changes made to open files will be lost. The next time you log onto the remote computer or server, a new FRESH session is created and printers restored.

What happens when you end a disconnected session running on the remote server?

You will see the Your Remote Desktop Services session has ended message, and the Remote Desktop client will close. But all programs and tests on the remote computer will continue running normally.

How do I keep a Windows server session alive?

To work around this issue, you can enable the Configure keep-alive connection interval policy in the Computer Configuration\Administrative Templates\Windows Components\Remote Desktop Services\Remote Desktop Session Host\Connections group policy folder. If you enable this policy, you must enter a keep-alive interval.


1 Answers

Yes, you can.

There are two types of sessions in Windows: The "console" session which is always active, and there can only be a max of one of, and "terminal" sessions, a la RDP. Using "rdpwrap" on Github, you can have an unlimited number of terminal sessions.

RDP sessions will become "deactivated" when there is not a connection to them. Programs will still run, but anything that depends on GUI interaction will break badly.

Luckily, we may "convert" a terminal session into a console session instead of disconnecting from Remote Desktop normally by running the following command from inside the terminal session:

for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (tscon.exe %%s /dest:console)

This will disconnect you from the session, but it will still run with full graphical context. This answers your question. You can reconnect to it and it will become a terminal session again, and you can do this infinitely. And, of course, autohotkey works perfectly.

But, what if you need more than one persistent, graphics-enabled session?

To get an unlimited amount of graphics-persistent sessions, you can run Remote Desktop and start terminal sessions from within the "main" session described above. Normally Remote Desktop prevents this "loopback" behavior, but if you specify "127.0.0.2" for the destination, you will be able to start a terminal session with any number of the users on the remote machine.

The graphics-persistentness will only be present on terminal servers if they are not minimized, unless you create and set RemoteDesktop_SuppressWhenMinimized to 2 at the following registry location:

HKEY_LOCAL_MACHINE\Software\Microsoft\Terminal Server Client

With this you can get an unlimited number of completely independent graphics-persistent remote sessions from a single machine.

like image 126
mp- Avatar answered Sep 20 '22 20:09

mp-