2

How to change exe name/description in Task Manager dynamically for different processes?

I have a console exe program (EXEConsole.exe) which will dynamically load some dlls for different work depends on the paramters.

So, it is possible I have 3 instance of EXEConsole.exe in the Task Manager, each runs with a different DLL. Now, I want to know which instance is running which DLL by looking at Task Manager. That's why I want to change the title/description of the EXEConsole in the Task Manager.

I could not figure out how to do it, so I have this idea:

When it needs to load a DLL, it copies the EXEConsole to a different folder, rename it based on the DLL's name, i.e. EXEConsole_MyDLL.exe, then run it. This somehow works for the purpose. But, is there a better way to do this?

Thanks

urlreader
  • 6,319
  • 7
  • 57
  • 91
  • It looks like that description is baked into resources in the EXE (https://stackoverflow.com/questions/4036830/how-do-i-modify-the-file-description-of-an-executable-using-msbuild-or-comman). That post points to a tool named verpatch. You could try spelunking through that source to see what it does. I know how to set up resources (managed and unmanaged), but I don't know if you can twiddle them on the fly. Also look at https://blogs.msdn.microsoft.com/oldnewthing/20130104-00/?p=5643/. RunDll32 didn't do what you want, that doesn't give me any hope for you – Flydog57 Jul 11 '18 at 19:07
  • 2
    You can't change that at runtime: https://stackoverflow.com/questions/20784925/c-sharp-set-process-description-on-run-time-or-earlier?rq=1 If you launch them with a different command, just like he says in the accepted answer, you can display that command – Tipx Jul 11 '18 at 19:16
  • Oh, or worst case, even though it's hacky, you could use different users to run each console, and base yourself on that. (Don't do this :-P ) – Tipx Jul 11 '18 at 19:16

1 Answers1

0

it seems there is no a good way to change it by code.

However, I do find a way to get around in my case. In case someone else needs to do this.

In the Task Manager, click the column title, choose 'Select Columns', check 'Command Line'. It will show the cmd which runs the program. In my case, this shows the DLL name, etc. So, I can know which DLL is this process for.

Thanks

urlreader
  • 6,319
  • 7
  • 57
  • 91