使用System.Diagnostics.Process()为进程设置映像名称和描述

时间:2022-06-18 19:44:05

How to set Image Name and Description for a process when using System.Diagnostics.Process() to start a process?

使用System.Diagnostics.Process()启动进程时如何设置进程的映像名称和描述?

So that it appears in the Windows task manager with desired name and description.

这样它就会出现在Windows任务管理器中,并带有所需的名称和描述。

For Example currently I am invoking some console application as shown below:

对于示例,我正在调用一些控制台应用程序,如下所示:

    static void Main(string[] args)
    {
        int incVal = 0;

        Process[] process = null;

        try
        {
            process = new Process[Properties.Settings.Default.TargetLayers.Length];

            for (incVal = 0; incVal < Properties.Settings.Default.TargetLayers.Split(',').Length; incVal++)
            {
                process[incVal] = new Process();

                process[incVal].StartInfo.FileName = "PMSchedulerTask.exe";

                process[incVal].StartInfo.Arguments = "\"" + Properties.Settings.Default.TargetLayers.Split(',')[incVal] + "$" + Properties.Settings.Default.TableMVRelation.Split('|')[incVal] + "\"";

                process[incVal].Start();
            }

            for (incVal = 0; incVal < Properties.Settings.Default.TargetLayers.Split(',').Length; incVal++)
            {
                process[incVal].WaitForExit();
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

Now I would like to have each process shown in the task manager with different Image Name and Description.

现在,我想让任务管理器中显示的每个进程具有不同的映像名称和描述。

1 个解决方案

#1


4  

These names are extracted by task manager from the executable image the process was started from. There is no setting to override this. Windows doesn't even know these strings exist. They are just part of the PE structure of the executable used to launch the process.

这些名称由任务管理器从进程启动的可执行映像中提取。没有设置可以覆盖它。 Windows甚至不知道这些字符串存在。它们只是用于启动进程的可执行文件的PE结构的一部分。

You could create a wrapper executable if you really need to do this.

如果你真的需要这样做,你可以创建一个包装器可执行文件。

#1


4  

These names are extracted by task manager from the executable image the process was started from. There is no setting to override this. Windows doesn't even know these strings exist. They are just part of the PE structure of the executable used to launch the process.

这些名称由任务管理器从进程启动的可执行映像中提取。没有设置可以覆盖它。 Windows甚至不知道这些字符串存在。它们只是用于启动进程的可执行文件的PE结构的一部分。

You could create a wrapper executable if you really need to do this.

如果你真的需要这样做,你可以创建一个包装器可执行文件。