Is the process name always an exe name?

I need to know if the process is running, but I do not want to hardcode its name. I would prefer to extract it from *.exe , so I did some experimentation and created a simple console application where I set the assembly name in the project properties to foo and then renamed foo.exe to bar.exe . I checked the running processes, and indeed, it was a bar that was running.

Is this by design and can I rely on this behavior or can the process have a different name from exe and does it apply to all types of exe files or only to .NET assemblies?

+6
source share
1 answer

You cannot change the name of the process image . This is installed by Windows and does not change. It will use the name of the executable to install it, so it can be used safely.

Instead of using a process to get an executable name, you can simply use the assembly name from .NET :

 System.AppDomain.CurrentDomain.FriendlyName 
+6
source

All Articles