Question: iam quite desperate here. I couldn't find any example code for this in C#.
I want to rename BrowserSubProcess.exe and i want it to embed my main exe, if possible. 

I am aware of this solution;

<https://github.com/cefsharp/CefSharp/issues/1149#issuecomment-225547869>

[Rename CefSharp.BrowserSubprocess winforms](https://stackoverflow.com/questions/36936884/rename-cefsharp-browsersubprocess-winforms)

but i couldn't implemented it. I need sample program or code to understand. I hope @amaitland will see this and helps me.

Answer: 
I embed the BrowserSubProcess Program.cs to my Program.cs so it is embedded now.

```
static class Program
{
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main(string[] args)
    {
        if (args.Count() < 5)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new LoginForm());
        }
        else
        {
            MyBrowserSubProcess(args);
        }
    }

    static int MyBrowserSubProcess(string[] args)
    {
        Debug.WriteLine("BrowserSubprocess starting up with command line: " + String.Join("\n", args));

        SubProcess.EnableHighDPISupport();

        int result;
        var type = args.GetArgumentValue(CefSharpArguments.SubProcessTypeArgument);

        var parentProcessId = -1;

        // The Crashpad Handler doesn't have any HostProcessIdArgument, so we must not try to
        // parse it lest we want an ArgumentNullException.
        if (type != "crashpad-handler")
        {
            parentProcessId = int.Parse(args.GetArgumentValue(CefSharpArguments.HostProcessIdArgument));
            if (args.HasArgument(CefSharpArguments.ExitIfParentProcessClosed))
            {
                Task.Factory.StartNew(() => AwaitParentProcessExit(parentProcessId), TaskCreationOptions.LongRunning);
            }
        }

        // Use our custom subProcess provides features like EvaluateJavascript
        if (type == "renderer")
        {
            var wcfEnabled = args.HasArgument(CefSharpArguments.WcfEnabledArgument);
            var subProcess = wcfEnabled ? new WcfEnabledSubProcess(parentProcessId, args) : new SubProcess(args);

            using (subProcess)
            {
                result = subProcess.Run();
            }
        }
        else
        {
            result = SubProcess.ExecuteProcess();
        }

        Debug.WriteLine("BrowserSubprocess shutting down.");

        return result;
    }

    private static async void AwaitParentProcessExit(int parentProcessId) 
    {
        try 
        {
            var parentProcess = Process.GetProcessById(parentProcessId);
            parentProcess.WaitForExit();
        }
        catch (Exception e) 
        {
            //main process probably died already
            Debug.WriteLine(e);
        }

        await Task.Delay(1000); //wait a bit before exiting

        Debug.WriteLine("BrowserSubprocess shutting down forcibly.");

        Environment.Exit(0);
    }

}

```

And my BrowserSubprocessPath is my main exe.

```
settings.BrowserSubprocessPath = System.AppDomain.CurrentDomain.FriendlyName;

```
I finally managed to rename this sub process! Haven't found any solution how to do it through the CefSharp API, but found my own worked solution.

So, In your code that uses CefSharp add one setting to the Cef Settings, before `Cef.Initialize()`

```
using CefSharp;
using CefSharp.Wpf;
using System.IO;
using System.Reflection;
using System.Windows;

public App()
{
    var settings = new CefSettings
    {
        BrowserSubprocessPath = Path.Combine(GetAppPath(), $@"runtimes\win-x64\native{ GetAppName() }.exe")
    };
    Cef.InitializeAsync(settings);
}

private static string GetAppPath()
{
    return new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName;
}

private static string GetAppName()
{
    return Assembly.GetExecutingAssembly().GetName().Name;
}

```

After this go to the `bin\Debug\net6.0-windows\runtimes\win-x64\native\` and rename `CefSharp.BrowserSubprocess.exe` to `Name you want to use`.

Done. Now it will use this file with custom name you need.

P.S. For the auto name set you can always use Post-Build event with command to rename the file after project built and set the name same as your assembly name. I use this approach for my needs.