I'm trying to script multiple remote desktop connections in a Winform .NET 4.0 in C#.
Given a list of server names in _serverList,
var startInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
RedirectStandardInput = true,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = false
};
var process = new Process { StartInfo = startInfo };
process.Start();
foreach (string server in _serverList)
{
process.StandardInput.WriteLine(@"mstsc.exe /v:" + server);
}
When I run it on my local desktop (Windows 7) it works perfectly fine: all servers are launched, but once i port the application onto the server (Windows Server 2003 r 2, and the event that triggers this occurs, I get the error
"mstsc.exe" was not recognized as an internal or external command, operable program or batch file
I attempted variations of providing the full path of mstsc.exe, changing FileName = "mstsc.exe" and providing the server names as Arguments, but none work.
When I launch cmd.exe on the server, and manually input "mstsc.exe /v: someservername", the behaviour is as expected and the proper servers are launched.
Any insight to what is going wrong would be appreciated