Archive: CONTRIB: Pre-Compile Prompt Dialog


CONTRIB: Pre-Compile Prompt Dialog
Prompt Before Compilation

Description
With a simple VBScript dropped on the system path, you can allow your NSIS scripts to prompt prior to compilation. I've found this useful to alert me to packages that require a significant amount of time to compile.

Usage

!system 'MsgBox.vbs "Package will take a long time to compile.\n\nAverage Compilation Time: 54 min 35 sec\n\n\tContinue?" "NSIS Compilation"' = 1
VB Script
Save the following VBScript as "MsgBox.vbs" in a location that is listed in the %PATH%.

'vbscript
'MsgBox.vbs


Dim Caption 'As String
Dim Prompt 'As String

'** Defaults
Caption = "What do you want to do?"
Prompt = "Proceed?"

'** Apply CmdLine Arguments
If WScript.Arguments.Count => 1 Then _
Prompt = WScript.Arguments.Item(0)

If WScript.Arguments.Count => 2 Then _
Caption = WScript.Arguments.Item(1)

'** Allow Meta characters
Prompt = Replace(Prompt, "\r", vbCr)
Prompt = Replace(Prompt, "\n", vbLf)
Prompt = Replace(Prompt, "\t", vbTab)

'** Display Prompt
WScript.Quit [COLOR=blue]MsgBox(Prompt, 289, Caption)

A smart way of handling stuff outside the compiler without the need for an extra open window. Thanks for sharing.


you could also create this script at run time with !appendfile and !delfile in $%temp%


Good Idea Anders!

Prompt Before Compilation

Description

Using a dynamic vbscript created at compile time, you can allow your NSIS scripts to prompt prior to compilation. I've found this useful to alert me to packages that require a significant amount of time to compile.
Usage

${!MsgBox} "WARNING: Package can take a long time to compile.\nAverage Compilation Time: 54 min 35 sec" "NSIS Compilation"
NSIS Macro
!define !MsgBox `!insertmacro _!MsgBox`
!macro _!MsgBox _Message _Caption
    !verbose push
    !verbose 0
    !tempfile MsgBox
    !appendfile "${MsgBox}" `WScript.Quit MsgBox(Replace(Replace(Replace("${_Message}","\t",vbTab),"\n",vbLf),"\r",vbCr),289,"${_Caption}")`
    !system `wscript.exe "${MsgBox}" //E:vbscript` = 1
    !delfile "${MsgBox}"
    !undef MsgBox
    !verbose pop
!macroend
Source: NSIS Wiki: Prompt Before Compilation