views:

1655

answers:

4

Hello. I'd like to have my executable's process be called ABC. How I can do this? I tried defining my project name to ABC, but then I'll have an ABC.vshost.

Thanks

+2  A: 

The best you can do is to set the assembly name in the property pages (Properties node in Solution Explorer) to whatever you wish. The C# compiler automatically uses the assembly name as the process name (file name of the generated EXE), so this should do the job for you. Note that the assembly name is completely independent from the project name and the root namespace.

You can of course change the file name of the EXE after it has been generated (and this will leave the assembly name unchanged), though I see no real reason for this.

Note: I assume you are referring to Visual Studio in particular, though it probably matters little in terms of what is possible.

Noldorin
+5  A: 

You can set this in the project's properties page. Setting the assembly name on the application tab will set the name of the resulting compiled assembly (ie. ABC.exe).

The .vshost.exe is the Visual Studio debugging process, used by Visual Studio when you debug. You can turn that off (Visual Studio does not need it to debug) by unchecking the "enable the visual studio hosting process" checkbox on the debug tab of the the project properties.

adrianbanks
Hi Adrian, I have another question. If we change the executable's name manually, the process name also changes. Is there a way to set the process name permanently?
Saurabh Lalwani
I don't believe so. The process name is the name of the executable that is running. The only thing I can think of is to have a check at startup that checks the current exe's name and will not run if it is not the expected one - that ensures your process is correctly named (albeit a horrible and unfriendly solution).
adrianbanks
Alright! I was just curious to know if it is possible or not.Thanks!
Saurabh Lalwani
A: 

The processes name in task manager is based of the image name, which is the executable (as already pointed out the assembly name setting defines this in VS.Net).

The Application Name is based on the window title, so is only something you can alter with graphical apps (except via dirty hacks to the console which are unlikely to be stable).

Note that you can have multiple executables all executing a common main method in a shared dll so you can 'name' different instances of essentially the same code differently if that helps.

ShuggyCoUk
A: 

It seems it's taken from the version-info resource for an .EXE; specifically, the "FileDescription" attribute. To do this programmatically, I imagine you would need a separate program to update the version-info resource in the .EXE whose description you're trying to change. (I don' know C#, but in C++, UpdateResource is used for this purpose.)

MunchyG