Prompt Before Compilation: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
(Rewrite as macro and to make it self contained.. no longer requires external vbscript file.)
m (→‎NSIS Macro: Cleanup and uncommented verbose lines.)
 
Line 11: Line 11:


== NSIS Macro ==
== NSIS Macro ==
Save the following VBScript as "MsgBox.vbs" in a location that is listed in the %PATH%.
<highlight-nsis>
<highlight-nsis>
!define !MsgBox `!insertmacro _!MsgBox`
!define !MsgBox `!insertmacro _!MsgBox`
!macro _!MsgBox _Message _Caption
!macro _!MsgBox _Message _Caption
     ;!verbose push
     !verbose push
     ;!verbose 0
     !verbose 0
     !tempfile MsgBox
     !tempfile MsgBox
     !appendfile "${MsgBox}" `WScript.Quit MsgBox(Replace(Replace(Replace("${_Message}","\t",vbTab),"\n",vbLf),"\r",vbCr),289,"${_Caption}")`
     !appendfile "${MsgBox}" `WScript.Quit MsgBox(Replace(Replace(Replace("${_Message}","\t",vbTab),"\n",vbLf),"\r",vbCr),289,"${_Caption}")`
Line 22: Line 21:
     !delfile "${MsgBox}"
     !delfile "${MsgBox}"
     !undef MsgBox
     !undef MsgBox
     ;!verbose pop
     !verbose pop
!macroend
!macroend
</highlight-nsis>
</highlight-nsis>


[[Category:Compile-Time Macros]]
[[Category:Compile-Time Macros]]

Latest revision as of 21:12, 10 November 2009

Author: Zinthose (talk, contrib)


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 will take a long time to compile.\n\
    Average 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