C#中Process.start指定为UseShellExecute=false问题怎样解决
当将Process.Start的UseShellExecute属性设置为false时,Process.Start将启动一个新进程来履行指定的可履行文件,而不是使用操作系统的Shell来履行。这可能会致使一些问题,下面是可能的解决方法:
Process process = new Process();
process.StartInfo.FileName = "your_executable_file_path";
process.StartInfo.UseShellExecute = false;
process.StartInfo.WorkingDirectory = "your_working_directory";
process.Start();
Process process = new Process();
process.StartInfo.FileName = "your_executable_file_path";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.Start();
string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
process.WaitForExit();
Process process = new Process();
process.StartInfo.FileName = "your_executable_file_path";
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = false;
process.Start();
这些解决方法可能会有所帮助,但具体要根据您的具体情况来决定最适合的解决方法。
TOP