Archive: Compile NSI file from BAT file


Compile NSI file from BAT file
Hi guys.


Normally when I want to compile a NSI file I can right-click on it and select "Compile NSIS Script" from the context menu.

Is it possible to compile a NSI from a BAT file?

I'm not being lazy or anything, it's just that I have a folder that contains quite a lot of NSI files, and it makes more sense to get a BAT file to compile them all rather than me having to right-click on all of them.


Thanks,
Si ++


makensis.exe "C:\myscript.nsi"

You can try:

Script:

Name "CompileNSI"
OutFile "CompileNSI.exe"
ShowInstDetails show

!include "FileFunc.nsh"
!insertmacro Locate
!insertmacro GetParameters

Section
ReadRegStr $R0 HKLM "SOFTWARE\NSIS" ""
IfErrors error
StrCpy $R1 0
StrCpy $R2 0

${GetParameters} $0
${Locate} "$0" "/L=F /M=*.nsi" LocateCallback

IfErrors error
DetailPrint ""
DetailPrint "$R1 from $R2 files compile with errors"
goto end

error:
MessageBox MB_OK "Error"

end:
SectionEnd

Function LocateCallback
nsExec::ExecToLog '"$R0\makensis.exe" "$R9"'
Pop $0
StrCmp $0 0 +2
IntOp $R1 $R1 + 1
IntOp $R2 $R2 + 1

Push 0
FunctionEnd

CompileNSI.bat:
@ECHO OFF
"CompileNSI.exe" C:\Path to yours scripts
CLS

Thanks, Instructor. I will give that a try.