1

I have a process with name as "processName" and executable as "processName.exe". I want to launch this process and change name of the process of how it appears in task manager. I can not just rename the executable because I want to have space in name. For example it should look like "ProcessName somethingelse" in task manager. I can see some programs doing this, for example for command prompt executable name is "cmd.exe" but name on command prompt is "Windows Command Processor" which has space in it's name.

sskarnik
  • 21
  • 1
  • 3

1 Answers1

2

The application/task name is the title of the main window (a chapter of its own). You can change your own title using SetWindowText:

BOOL SetWindowTextA( // Ansistring version
  HWND   hWnd,       // handle to your main window
  LPCSTR lpString    // new name
);

or

BOOL SetWindowTextW( // Widestring version
  HWND    hWnd,
  LPCWSTR lpString
);
Ted Lyngmo
  • 93,841
  • 5
  • 60
  • 108
  • Task Manager prefers to use the FileDescription from the PE image version info as the application name (e.g. "Windows Command Processor" for cmd.exe). Console applications get grouped under the effective owner of the console (usually the process that allocated it, unless it already exited). This group includes conhost.exe, which is the real owner of the console window. UWP apps have windows hosted by an instance of applicationframehost.exe, but they get grouped separately by package, and in this case, in contrast to the console, the window host process is excluded as a background process. – Eryk Sun Dec 03 '18 at 20:34
  • I'm on W7 and there the task name for `cmd.exe` shown in the Task Manager seems to come from its WindowText. Changing it using `SetWindowTextW` changes the task name anyway. Will this not work on later Windows versions (for `cmd.exe` or ones own apps)? – Ted Lyngmo Dec 03 '18 at 21:53
  • I was describing how Task Manager works in Windows 10, and probably Windows 8, which generally shows the file description that's embedded in the PE image as the application name, as opposed to the window text of the first top-level window that's owned by the application. UWP apps are an exception, however. They use the package application name, and their windows are hosted out of process in the session's applicationframehost.exe process. – Eryk Sun Dec 04 '18 at 00:11
  • 1
    I got my hands on a W10-machine to test and I see what you mean. One has to click the expand arrow on an app to see its Windows titles, although in the Task bar they are show as before. Is there a way to change the actual name/description without changing the PE image? You said that it _generally_ uses that description which sounds promising, if this is what OP wants. – Ted Lyngmo Dec 04 '18 at 07:21