Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change process name in C#?

Tags:

c#

.net

Is it possible to change the name of a currently executing process in C# (or .NET in general)? I believe it isn't possible, but my co-worker is trying to solve a problem under the assumption that it is.

like image 318
Taylor Leese Avatar asked Sep 10 '09 00:09

Taylor Leese


People also ask

How do I name a process in C++?

C++ has no notion of process names. Some specific operating systems do. If you mention which one you're using it would probably help. then use the HINSTANCE params, if you are using a Console app, then look for a tutorial on attaching a Console. you are handed two HINSTANCE'es, the current instance, and the previuse instance.

How do I change the process name of a process?

In language like C, a process can change its name by changing argv [0]. Higher level language also allows you to do this, example in Perl, you can modify $0 variable to change process name.

How do I change the program name on the command line?

There is a catch, which is that "ps" and "top" can show you either the "command line" or the "program name", and we can only modify the command line. If you are running top, you can hit the "c" key to switch between which one it shows.

How do I kill multiple processes under the same name?

You can start more than one process under the same name, then pkill -f <name> will kill all of them. Show activity on this post. I had an issue with an audio transcoding tool that ran 3 times under the same name.


1 Answers

No it is not possible to change the name of the currently executing process. Process names are defined by the name file which was loaded into the operating system for execution at the time execution began. You cannot change this at a later point. This is true for C#, managed and native code.

like image 200
JaredPar Avatar answered Oct 03 '22 01:10

JaredPar