有没有办法在 NSIS 脚本的 DetailPrint 中链接一部分文本以指向文件?

问题描述

示例: DetailPrint "在运行安装后脚本时检测到错误。单击此处查看结果。"

单击“此处”应将用户带到特定文件

解决方法

日志窗口只是一个ListView控件,不支持这个。

您可以向用户显示一条消息:

Section
; Post install steps...
MessageBox MB_YESNO|MB_ICONQUESTION "There was a problem,view results?" /SD IDNO IDNO skipresults
    ExecShell "" "$Temp\InstallError.log"
skipresults:
SectionEnd

或者您可以显示一个带有链接的自定义页面:

!include nsDialogs.nsh
!include LogicLib.nsh

Page Directory
Page InstFiles
Page Custom myPostFailureCreate


Var PostFailure

Function OpenPostReport
ExecShell ...
FunctionEnd

Function myPostFailureCreate
${If} $PostFailure = 0
    Abort
${EndIf}

nsDialogs::Create 1018
Pop $0
${NSD_CreateLabel} 5u 0 80% 12u "Install scripts failed!"
Pop $0
${NSD_CreateLink} 5u 13u 80% 12u "View report"
Pop $1
${NSD_OnClick} $1 OpenPostReport
nsDialogs::Show
FunctionEnd

Section
; Post install steps...
${If} ${Errors}
    StrCpy $PostFailure 1
${EndIf}
SectionEnd