當前位置:首頁 > IT技術 > Windows編程 > 正文

C#轉接遠程桌面直接傳入用戶名和密碼
2021-10-18 17:36:47

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/

開通會員,享受整站包年服務立即開通 >