Click here to Skip to main content
15,868,164 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

i want to connect to the remote desktop without the username window.
Already i ve tried
cmdkey /generic:172.21.55.185 /user:"username" /pass:"password"
mstsc /v:172.21.55.185

This method still prompts connect window and then security certificate window. is there a way by which i can directly move into the desktop of the remote machine ?
Posted
Comments
Kornfeld Eliyahu Peter 9-Jun-15 16:04pm    
How do you run these command from C#?
Member 8358911 9-Jun-15 16:50pm    
Like this.

Process rdcProcess = new Process();
rdcProcess.StartInfo.FileName = Environment.ExpandEnvironmentVariables(@"%SystemRoot%\system32\cmdkey.exe");
rdcProcess.StartInfo.Arguments = "/generic:172.17.21.185 /user:" + "username" + " /pass:" + "password";
rdcProcess.Start();

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

The problem is that you are running those commands in two different processes (even you use the same object you run Start twice) so the username and password has no effect on the RDP command...
(Actually reuse of the process object is not supported and may have unexpected results)...
So you have to run it in a single call...
You may use the /c command line options of cmd.exe like this:
C#
String szCmd = "/c cmdkey.exe /generic:ip /user:username /pass:password & mstsc.exe /v ip";
ProcessStartInfo info = new ProcessStartInfo("cmd.exe", szCmd);
Process proc = new Process();
proc.StartInfo = info;
proc.Start();
 
Share this answer
 
Comments
Member 8358911 10-Jun-15 3:23am    
Even this solution prompts the "connect" and "certificate" window. I couldnt directly move into the remote desktop once i run this code.
Kornfeld Eliyahu Peter 10-Jun-15 3:32am    
If you mean by 'connect' window the window asks you 'Do you trust this remote connection?', then it is not connected to the identification! It is an 'external' part of the process, that ensures no code without the approval of the end user can connect to remote machine (and make some damage). You can stop this window only manually by checking the box...
The second window you see (certificate) also connected the security part of the process...
It means that you asked for a computer by ip but it returned a name so it may be some computer only faking to be the one you wanted and just waiting to do some damage - this window too can be stop only manually...
I solved this by disabling both the windows.

http://weblogs.asp.net/owscott/Vista_2700_s-Remote-Desktop-Prompt[^]

Thank you
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900