Change the program name of exe on UAC

2019-08-06 13:04发布

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?

标签: c# uac signtool
1条回答
你好瞎i
2楼-- · 2019-08-06 13:46

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.

查看更多
登录 后发表回答