0

I want to connect to a remote machine using mstsc.exe without username and password. As I want to connect it without username and password then it should get connect with lock session status.

So I want something like this,

  1. User will enter IP address and hit connect button.
  2. Machine should get connected with lock status.

I already tried below code but it did not work.

        Process rdcProcess = new Process();
        rdcProcess.StartInfo.FileName = Environment.ExpandEnvironmentVariables(@"%SystemRoot%\system32\mstsc.exe");
        rdcProcess.StartInfo.Arguments = "/v " + "123.0.0.1 /public"; // ip or name of computer to connect
        rdcProcess.Start();

Is there any way user will be able to do this using C#?

Thanks

-Sanket

Sanket Shah
  • 461
  • 2
  • 7
  • 17

1 Answers1

0

This is not possible - the Remote Desktop server in Microsoft Windows does not allow unauthenticated incoming connections, for obvious reasons. User accounts that do not have a password set cannot login to Remote Desktop, and there is no configuration option to allow anonymous authentication.

As an alternative, I suggest using a VNC server, which works differently (it shares the session the VNC server was started in and mirrors the session's framebuffer, as opposed to a true Remote Desktop session which is separate from other sessions and uses GDI redirection). You can configure a VNC server to not require a password to connect, but this is strongly discouraged, of course.

However, I'm not aware of any VNC servers that only allow at most 1 connection and prevent secondary connections, but as almost the entire VNC ecosystem is open-source you can probably modify an existing server to behave the way you want it to. One possibility is to set-up a VNC server without a password, then as soon as a user connects it sets a new randomly generated password, thus preventing other clients from connecting. It would clear the password when the current client disconnects.

Dai
  • 141,631
  • 28
  • 261
  • 374