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.
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With