void Main() { var ip = "192.168.0.x"; var username = "administrator"; var password = "123456"; Process rdcProcess = new Process(); rdcProcess.StartInfo.FileName = Environment.ExpandEnvironmentVariables(@"%SystemRoot%system32cmdkey.exe"); rdcProcess.StartInfo.Arguments = string.Format( "/generic:TERMSRV/{0} /user:{1} /pass:{2}",ip,username,password); rdcProcess.Start(); rdcProcess.StartInfo.FileName = Environment.ExpandEnvironmentVariables(@"%SystemRoot%system32mstsc.exe"); rdcProcess.StartInfo.Arguments = "/v " + ip; // ip or name of computer to connect rdcProcess.Start(); }
?
本文摘自 :https://www.cnblogs.com/