프로그램(C# etc.)

c#에서 chrome.exe --remote-debugging-port=9222 --user-data-dir="c:/ChromeTEMP" CMD명령 하도록 코드 보여줘

질문폭격 2023. 2. 3. 17:57

 다음은 C#에서 "chrome.exe --remote-debugging-port=9222 --user-data-dir="c:/ChromeTEMP" 명령을 실행할 수 있는 방법의 예입니다.

using System;
using System.Diagnostics;

namespace ChromeCommandExample
{
    class Program
    {
        static void Main(string[] args)
        {
            ProcessStartInfo startInfo = new ProcessStartInfo();
            startInfo.FileName = "chrome.exe";
            startInfo.Arguments = "--remote-debugging-port=9222 --user-data-dir=\"c:/ChromeTEMP\"";

            try
            {
                using (Process process = Process.Start(startInfo))
                {
                    Console.WriteLine("Chrome started successfully with the following command: {0} {1}", startInfo.FileName, startInfo.Arguments);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error starting Chrome: {0}", ex.Message);
            }
        }
    }
}