Change name of process in Task Manager [duplicate]
Asked Answered
Q

2

6

I have a windows form application running on a server. Now I need to have multiple instances of the same application running at the same time. Each instance will connect to a different database. During the application startup I change the title so I can identify which DB is connecting to, but I'd like to change the name in the Task Manager also. This because I have another application that act as a supervisor, killing and starting the process as needed. I have to find a way to clearly identify the process to kill.

Quell answered 5/2, 2013 at 15:32 Comment(8)
Can your Supervisor app be the one who starts the processes so that you have the PIDs from the start? Or does it need to be able to run separately?Carom
@Destrictor: I do not believe this is the same question. He wants to have multiple instances with different names, not just one new name.Carom
Destrictor the link does not provide any real solution WabeMax look at this answer for an alternative way of doing this #1017323Muscadine
@leppie That won't work. Task manager shows the name of the original executable (e.g. try mklink foo.exe %windir%\system32\notepad.exe, will still show notepad.exe in Task Manager).Alerion
Yes, usually the Supervisor is the one that starts the process, but that's not a guarantee. Sometimes some "admin" user play God killing and starting processes manually.Quell
@Christian.K: Oops, my bad :)Ramah
Make a copy of the exe. Rename to liking.Ramah
Sorry leppie, your comment was hiding behind the "show more" before I posted my comment.Kerrykersey
K
1

Have your supervisor create a temporary copy of the executable, including your identifying information, and start that... so that Task Manager will look like

My process - database 1.exe
My process - database 2.exe
et cetera
Kerrykersey answered 5/2, 2013 at 19:20 Comment(0)
C
0

If the Supervisor program is the one starting the processes, you will have full control over these child processes. You can easily kill/start them as you need. Use Process as needed.

using System.Diagnostics;

Process p1 = new Process();
Process p2 = new Process();
Process p3 = new Process();

p1.StartInfo.FileName = "notepad.exe";
p2.StartInfo.FileName = "notepad.exe";
p3.StartInfo.FileName = "notepad.exe";

//start the procs
p1.Start();
p2.Start();
p3.Start();

//kill the procs
p1.Kill();
p2.Kill();
p3.Kill();

If you want some superuser to have access to kill the process, why not let them just do it with the GUI? If there is no GUI, how are they running the program? Is it started via cmd?

Copied from my comment below:

If the user wants to be able to kill the process from the taskmanager specifically, they can use the applications tab to pick the correct process (you will need to give it a unique window title), then they can right click>Go To process and kill from there.

Carom answered 5/2, 2013 at 15:58 Comment(2)
There is a GUI with a "Stop" button, it's just that those "superuser" feel like it's more "professional" to kill via Task Manager.Quell
Haha... ok... Maybe put a unique identifier in the title window. For example, "Program DB-ABC", then they can click "Go to process" from the applications tab for that window. You could also display the current PID somewhere, and they can use command prompt to kill the process. ex: TASKKILL /PID 1230Carom

© 2022 - 2024 — McMap. All rights reserved.