简体   繁体   English

NSIS以静默方式安装后弹出对话框/消息

[英]Popping up a dialog/message after NSIS install in silent mode

I have an NSIS installer set to run in silent mode. 我将NSIS安装程序设置为以静默模式运行。 This works very well. 这很好。

I've had a customer request for an informational pop up once the install has complete...but still wants the installer portion to be silent! 安装完成后,我曾有客户要求弹出信息提示框...但仍然希望安装程序部分保持沉默!

I realize this is counter intuitive. 我意识到这是反直观的。

That being said is there away to override the silent at the end of the install? 话虽这么说,在安装结束时是否有替代静默的方法?

I currently set the installer attribute below at the beginning of the .nsi script 我目前在.nsi脚本的开头在下面设置了installer属性

SilentInstall silent

You can toggle silent mode on or off in .onInit with SetSilent but once that function returns the UI mode cannot be changed. 您可以使用SetSilent.onInit打开或关闭静音模式,但是一旦该函数返回,则无法更改UI模式。

The simple solution is to simply use one of the Banner or Splash plug-ins at the end of your last Section to display a message/image. 简单的解决方案是仅在最后一Section的末尾使用BannerSplash插件之一来显示消息/图像。

Or you can create a fake silent mode with a minimal UI that only displays the progress bar: 或者,您可以使用最小的UI创建伪造的静默模式,该UI仅显示进度条:

!include LogicLib.nsh
Var Silent

Function .onInit
${If} ${Silent}
    SetSilent Normal ; Turn off real silent mode
    SetAutoClose True
    StrCpy $Silent 1 ; Fake silent mode
${EndIf}
FunctionEnd

Page Components SkipPageIfSilent
Page Directory SkipPageIfSilent
Page InstFiles "" TweakInstfilesPage

Function SkipPageIfSilent
IntCmp $Silent 0 +2
    Abort
FunctionEnd

Function TweakInstfilesPage
${If} $Silent <> 0
    SetSilent Silent ; Make IfSilent return true
    FindWindow $0 "#32770" "" $HWNDPARENT
    GetDlgItem $0 $0 0x403 ; Show details button
    ShowWindow $0 0
    System::Call 'USER32::GetWindowRect(p$0,@r1)' ; NSIS v3+
    System::Call 'USER32::GetWindowRect(p$HWNDPARENT,@r2)' ; NSIS v3+
    System::Call '*$1(i,i.r3,i,i)'
    System::Call '*$2(i.r5,i.r6,i.r7,ir3r8)'
    IntOp $5 $7 - $5 ; Width
    IntOp $6 $8 - $6 ; Height
    System::Call 'USER32::SetWindowPos(p$HWNDPARENT,p,i,i,ir5,ir6,i0x12)'
    SetDetailsView Hide
${EndIf}
FunctionEnd

Section
Sleep 333
Sleep 333
Sleep 333
Sleep 333
SectionEnd

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM