設置一下Process類型相關的配置屬性即可,直接上代碼。
//記得引入命名空間
//using System.Diagnostics;
//獲得當前環境的基路徑
string basePath = Environment.CurrentDirectory;
//設置要啟動的程序文件位置
string filePath = @"\website\panda.exe";
ProcessStartInfo startInfo = new ProcessStartInfo(basePath + filePath);
//設置不在新窗口中啟動新的進程
startInfo.CreateNoWindow = true;
//不使用操作系統使用的shell啟動進程
startInfo.UseShellExecute = false;
//將輸出信息重定向
startInfo.RedirectStandardOutput = true;
//新建進程
Process process = new Process();
//設置啟動信息
process.StartInfo = startInfo;
//啟動進程
process.Start();