process打開程序

process打開應用程序的時候,最好要指定工作目錄,否則會出現一些錯誤

 private static void StartRobot(string path, string exe)
        {
            Process myProcess = new Process();
            try
            {
                myProcess.StartInfo.UseShellExecute = false;
                myProcess.StartInfo.FileName = Path.Combine(path, exe);
                myProcess.StartInfo.WorkingDirectory = path;
                myProcess.StartInfo.CreateNoWindow = true;
                myProcess.StartInfo.Verb = "RunAs";
                myProcess.Start();

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章