我正在尝试使用C#以统一方式执行命令行提示,我首先需要将目录更改为C://Users//HP//Documents
然后执行应该在Documents下的命令,这就是我一直在做的事情:
ProcessStartInfo proc = new ProcessStartInfo ("cmd.exe");
proc.UseShellExecute = false;
proc.RedirectStandardOutput = true;
proc.CreateNoWindow = true;
proc.RedirectStandardInput = true;
var process = Process.Start (proc);
process.StandardInput.WriteLine(@"cd C://Users//HP//Documents");
process.StandardInput.WriteLine ("MyCommandLine");
MyCommandLine应该在Documents下创建一个文本文件,但每次执行该函数时Unity都会阻塞。 任何人都可以帮我这个。
答案 0 :(得分:1)
运行" MyCommandLine"后,您的cmd.exe进程永远不会退出。添加"退出"像这样的命令
process.StandardInput.WriteLine("exit");