Can the GUI of an RDP session remain active after disconnect

寵の児 提交于 2020-12-28 07:42:33

问题


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.


回答1:


This could be a workaround, altough I have not tried it myself and it involves having another machine

Let's assume that at the moment you are creating a session to myserver.com

Local Client ----> myserver.com

Instead of doing that, you could try having a separate server (let's call it myslave.com) and use that to establish a session

Local Client ----> myslave.com ----> myserver.com

Then if you disconnect the Local Client ---> myslave.com session the GUI of the session between myslave.com ----> myserver.com should remain active.

It will work only if you are connected to the console session of myslave.com.




回答2:


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.




回答3:


I found a similar way. I had same problem, i downloaded rdp wraper which allows you configure multiple session rpd server and one tool which is included (rdpchecker.exe) allows you connect to localhost so you can connect to your server from your server and you dont need that middle client.




回答4:


This could be a workaround, altough I have not tried it myself and it involves having >another machine

Let's assume that at the moment you are creating a session to myserver.com

Local Client ----> myserver.com

Instead of doing that, you could try having a separate server (let's call it myslave.com) and use that to establish a session

Local Client ----> myslave.com ----> myserver.com

Then if you disconnect the Local Client ---> myslave.com session the GUI of the session
between myslave.com ----> myserver.com should remain active

If you are using a windows server you don't even need another machine.

1) Connect to the server with the remote desktop connection (#con1).

2) Create a new alias for your server system like "127.0.0.2" in Windows\System32\drivers\etc\hosts .

3) Now establish a new remote desktop connection from your windows server (in #con1) to itself (#con2).

4) Finally start your GUI needing application e.g. UI-Path in #con2 and then close #con1.


来源:https://stackoverflow.com/questions/15887729/can-the-gui-of-an-rdp-session-remain-active-after-disconnect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!