1
votes

I have process, that run multiple times child processes (each without GUI), and it needs to set to all child processes different "names" and "description" for Task Manager. Is it possible using Win API? I can't find solution for Windows family.

I look to WriteProcessMemory, but it looks like form of cheating, even if there is possible to change name. Solution with copying .exe file, run it, and after process finished - deleting it - is even more cheating. There may be exist solution using start process from memory (so, I load exe file to memory, then start it from there), but it also looks bad and I'm not sure I will be able to change name.

I hope there have to be solution to set process name to my own child process, isn't it?

1
Are you trying to make a virus that fools task manager into showing something else that actually is going on?Öö Tiib
no, different processes starts with different parameters and do different tasks, and I want to help administrator to understand which one is working, which one not, and what is going on, instead of watching 26 processes with same names. I believe if person write virus, he is able to use any trick I listed above to achieve that :-)Arkady
I don't ask about changing name of existing process, but if I start my own process, why can't I choose it's name, instead of renaming executable?Arkady
On that case isn't it lot simpler to write your own special administrator/monitoring tool for your multiprocessing solution instead of fooling/hacking task manager to do something that it is not meant for?Öö Tiib
Processes don't have "names" in Windows but "handles". What you talk about is "executable file name" for a process that you want to change for to display your solution-specific meta information about it in task manager.Öö Tiib

1 Answers

6
votes

You can't change the "Image Name" that appears in Task Manager. As you found, Windows obtains that from the name of the file that is actually executing and the only way to have something different appear is to actually run a file with a different name (such as by copying your executable).

If you are targeting newer versions of Windows, Task Manager can display a "Command Line" column (View -> Select Columns). You can make your processes distinguishable by including a particular flag in the command line, or by setting the first token of the lpCommandLine argument to something unique - you just have to also set the lpApplicationName argument to the actual executable you want to run so the loader can find it.

For example:

BOOL ret1 = CreateProcess(
               "c:\\program\\worker.exe",
               "worker1.exe infile outfile",
               ...);

BOOL ret2 = CreateProcess(
               "c:\\program\\worker.exe",
               "worker2.exe infile outfile",
               ...);

These will have identical Image Name values in Task Manager, but they will be distinguishable by the Command Line values.