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);
            }
        }

 

posted @ 2022-02-24 16:45  一条大河啊波浪宽啊  阅读(77)  评论(0编辑  收藏  举报