如何使用 System.Diagnostics.Process 类在 c# 中的远程计算机上启动进程,例如计算机名称 =“someComputer”?
我在那台远程计算机上创建了一个小型控制台应用程序,它只是将“Hello world”写入一个 txt 文件,我想远程调用它。
控制台应用程序路径:c:\MyAppFolder\MyApp.exe
目前我有这个:
ProcessStartInfo startInfo = new ProcessStartInfo(string.Format(@"\\{0}\{1}", someComputer, somePath);
startInfo.UserName = "MyUserName";
SecureString sec = new SecureString();
string pwd = "MyPassword";
foreach (char item in pwd)
{
sec.AppendChar(item);
}
sec.MakeReadOnly();
startInfo.Password = sec;
startInfo.UseShellExecute = false;
Process.Start(startInfo);
我不断收到“找不到网络路径”。