问题
I have an exe which when tried to run as administrator shows the program name as TestSampleConsoleSign.exe. Its a simple console application with hello world in it.
namespace TestSampleConsoleSign
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World");
Console.ReadLine();
}
}
}
I have also changed the AssemblyTitle field in AssemblyInfo.cs to HelloWorld. But when UAC is enabled the program name still shows as TestSampleConsoleSign.exe instead of HelloWorld. I also tried to signtool by creating a digital certificate using this : http://msdn.microsoft.com/en-us/library/ff699202.aspx and signing my exe with following command
signtool sign /f test.pfx /p password /d HelloWorld TestSampleConsoleSign.exe
I found this solution on How change attributes to UAC? What am I missing? Is this mandatory- How change attributes to UAC?
回答1:
First I confirm that changing AssemblyTitle
in AssemblyInfo.cs is the correct place. Note that this field shows up as File Description in the properties details page of Windows Explorer. Maybe you want to double check whether your AssemblyTitle appears there, just to make sure that you have really triggered a rebuild.
Then I tried running a Console application like yours with different certificates and the following happened:
- Self-created certificate (like yours): UAC shows the program's executable name.
- "Official" certificate with a trusted root authority: UAC shows the file description (AssemblyTitle)
Funny though: even if I change the executable name to something containing "Setup", the UAC dialog was not shown. For the UAC dialog to be shown, I had to check the checkmark "Run as administrator". Running as administrator might be your default, if you have included an app.manifest file with such a setting.
来源:https://stackoverflow.com/questions/21702044/change-the-program-name-of-exe-on-uac