【问题标题】:The UAC prompt shows a temporary random Program Name for msi, can the correct name be displayed?UAC提示为msi显示一个临时随机的Program Name,能显示正确的名称吗?
【发布时间】:2026-01-26 10:30:01
【问题描述】:

我正在为 Windows 构建一个 MSI 安装程序,并使用 signtool 对安装程序进行签名。当我运行 .msi 对其进行测试时,会出现 UAC(用户帐户控制)提示,询问我是否要允许安装继续进行。这很好,但提示显示了许多字段,并且对于程序名称字段,它显示类似“403b3.msi”的内容。这不是我正在运行的 msi 的名称。

我怎样才能得到正确的程序名称来显示?

【问题讨论】:

    标签: windows certificate uac signtool


    【解决方案1】:

    在执行 signtool 对 msi 进行签名时,使用带有所需程序名称的 /d 命令行参数。

    Windows 安装程序似乎创建了 msi 文件的临时副本,并在运行之前为其分配了一个生成的名称。如果您不将 /d 与 signtool 一起使用,您会看到临时文件名,这对您的用户不是很有用。

    【讨论】:

    • 添加 /d 时,您还需要一个描述。 IE:/d“我的应用程序!”
    【解决方案2】:

    这是@Scott-langham 评论的应用版本。

    这直接来自 Visual Studio 安装程序项目的 PostBuildEvent - VDPROJ 文件

    set signtool="C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\signtool.exe"
    set timestampurl=http://timestamp.digicert.com
    set certpath="$(ProjectDir)CodeSigningCert.pfx"
    
    :: Setup in your user environment variables
    :: using something with low sort order to force off screen ZZCODECERTPASSWORD
    if []==[%ZZCODECERTPASSWORD%] (
    echo must set code signing certificate in ZZCODECERTPASSWORD environment variable. stopping build.
    exit /b 2
    )
    
    :: need the filename with extension that is being generated
    FOR /f %%i IN ("$(BuiltOuputPath)") DO (
    SET outputfilename=%%~nxi
    )
    
    %signtool% sign /t %timestampurl% /f %certpath% /p %CODECERTPW% /d %outputfilename% "$(BuiltOuputPath)"
    IF ERRORLEVEL 1 (
    echo failed to sign MSI
    exit /b 3
    )
    
    %signtool% sign /t %timestampurl% /f %certpath% /p %CODECERTPW% "$(ProjectDir)$(Configuration)\Setup.exe"
    IF ERRORLEVEL 1 (
    echo failed to sign boostrap setup EXE
    exit /b 4
    )
    

    【讨论】:

    • 对于格式不正确的评论,我们深表歉意。无法弄清楚如何使换行符起作用...我成功地使用了它,除非您的路径中有一个或多个空格,则需要进行更改。在顶部使用它进入局部变量:set outputdir=$(BuiltOuputPath)。然后像这样使用新变量:FOR %%i IN ("%outputdir%") DO ( SET outputfilename=%%~nxi ),然后在脚本中使用:%signtool% sign /a /t %timestampurl% /d "%outputfilename%" "%outputdir%" IF ERRORLEVEL 1 ( echo failed to sign MSI exit /b 3 )
    • @GaryWillette 很高兴这对您有所帮助。 >如果你的路径有一个或多个空格
    • $(BuiltOutputPath)
    最近更新 更多