ASP.NET アプリケーションから RDP を開こうとしています。接続パラメーターを使用して .rdp ファイルを作成するメソッドを作成しましたが、このメソッドを実行しようとすると、次のエラーが発生しました。
c:\temp.rdp からの読み込み中にエラーが発生しました
これが私のコードです:
public static void RdcTest(string server, string domain, string username, string password)
{
string encyptedPassword = "";
//Calling the CryptUnprotectData API to encypt the password,
//Read this link for how to do this:
//http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework/topic21805.aspx
string filename = @"c:\temp.rdp";
if (!File.Exists(filename))
{
using (FileStream fs = File.Create(filename))
using (StreamWriter sw = new StreamWriter(fs))
{
sw.WriteLine("screen mode id:i:2");
sw.WriteLine("desktopwidth:i:1440");
sw.WriteLine("desktopheight:i:900");
sw.WriteLine("full address:s:" + server);
sw.WriteLine("username:s:" + username);
sw.WriteLine("domain:s:" + domain);
sw.WriteLine("password 51:b:" + encyptedPassword);
}
Process rdcProcess = new Process();
string strExE = Environment.ExpandEnvironmentVariables(@"%SystemRoot%\system32\mstsc.exe");
rdcProcess.StartInfo.FileName = strExE;
rdcProcess.StartInfo.Arguments = filename;
rdcProcess.Start();
}
}
どんなアイデアでも大歓迎です!