Solve the problem of automatically locking the screen after Windows Server is remotely disconnected

1. Problem description

Everyone has basically used the desktop version of Windows. If I have something to do temporarily and turn off the screen power of the monitor, what impact will this operation have on my running windows desktop? The answer is that it has no effect. What the desktop looked like before you left will remain the same after you turn off the monitor. Turning off the monitor just makes you unable to see the desktop. Of course, if you have set up a scheduled screen saver, scheduled automatic shutdown of the screen, or scheduled automatic standby function, etc., the computer will perform corresponding operations at the preset time, but at least during the period when you just turned off the monitor, the Windows desktop will remain. as is.

So for the desktop of Windows Server, if I disconnect the Remote Desktop Connection (remote desktop connection), what effect does this operation have on my Windows desktop? The answer is that your Windows Server desktop immediately entered the lock screen state. If your services are only background services, then locking the screen is actually not a big problem; but if your program or service must run normally without locking the screen, you will find that once you disconnect the Remote Desktop Connection (Remote Desktop Connection), then your programs will immediately stop serving, because the environment in which they normally run does not exist. So how to solve this problem?

The reason for the problem is that the remote desktop is disconnected, which leads to the lock screen, which in turn causes the program or service to fail to run, so the solution is very straightforward, just keep the remote desktop from disconnecting. The first solution that can be thought of is to keep your PC connected to the remote desktop and do not disconnect it, so that the desktop on the server side will never lock the screen. But this will also cause a problem, my pc may not be able to turn on 24 hours a day, and if my pc can turn on 24 hours a day, I don't even need to run my program to the server, it is enough to use it directly on my pc , obviously this method is not feasible. The second thing I can think of is that I use another server to remotely log in to this server, and the remote connection has not been disconnected, so that I can also ensure that the desktop of my server is not locked. This method is no problem for users with a lot of resources, just open another server. But what about light users? There is only one server in hand, and there is no way to allow other servers to remotely connect to your own server. According to the above scenario, there is a super solution in this article-remote yourself by yourself.

Two, the solution

Yes, you heard that right, remotely yourself. It didn't subvert your cognition, and it didn't go beyond the boundaries of theory. Remotely by yourself, first, it can solve the problem that the PC cannot be turned on 24 hours a day, and second, it can solve the embarrassment of only one server. The most important thing is that it is theoretically and practically feasible.

Let's talk about the operation method in detail.

  1. Create a new user

Usually, we use the Windows Server version and log in with the administrator account. In order to remote yourself, you need to create another account. As for whether you are an administrator or an ordinary user, I don’t have any requirements in this method, it depends on the requirements you want to run the program. Assume here that I created another windows user named zys.

  1. Remote from the main account to the newly created account

Taking the above user information as an example, first log in remotely to the administrator account of the windows server, and then open the Remote Desktop Connection (remote desktop connection) here again. Logging in is the most convenient, if you can’t use it, you can also try the public network ip), the target user is zys, and log in.

  1. Run your program in the user of the newly created account

In the remote window of the newly created account, open the program you want to run. Here is the program you want to run from the desktop of zys.

  1. When disconnecting, only disconnect the remote desktop between your PC and the administrator account

After the program runs, if you don't need to pay attention any more, just disconnect the remote connection between your PC and the main server account. The window from the main account to the newly created account is always open. Taking this article as an example, it is to disconnect the remote connection between my PC and the administrator, and the remote desktop between the administrator and zys remains open.

After the above operations, you will find that even if you disconnect the remote window between the PC and the server, your program can still run normally, because your server is remote itself, so the desktop of the sub-account will never lock the screen.

3. Summary

For server-side programs that must be run without locking the screen, you can use the "remote yourself" method to ensure that an account in the server is always in the remote state and will not enter the lock screen mode.

Guess you like

Origin blog.csdn.net/VBcom/article/details/128704298