Archive: WRITE INI while compiling


WRITE INI while compiling
Hi

I need help. I have a script, that installs a set of new files into a program. After the setup a INI file I updated by the new version number, that is set manually.
I want to change the script, but i do not know how to handle.
How is it possible to write the INI file during the compilation, before the files are packed into the setup?

Here is the script. Hope you can help:

-------------------------------------------------------------------------
; Script generated with the Venis Install Wizard
!define APPNAME "Diagnose"
!define APPTYPE "Daten"
!define APPVERSION "3.2.3"
!define APPNAMEANDVERSION "${APPNAME} ${APPTYPE} ${APPVERSION}"

!include "Sections.nsh"

Var DIAGNOSEHOME

; Main Install settings
Name "${APPNAMEANDVERSION}"
InstallDir "$PROGRAMFILES\Diagnose\"
;InstallDirRegKey HKLM "Software\${APPNAME}" ""
OutFile "C:\Daten\Diagnose\generierte Setup-Files\Setup ${APPNAMEANDVERSION}.exe"
SetCompressor lzma

; Modern interface settings
!include "MUI.nsh"
!define MUI_ABORTWARNING


!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

; Set languages (first is default language)
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_RESERVEFILE_LANGDLL

Section "PUDIS Daten" Section1
; Eventuell vorhandene Installation entfernen
RMDir /r "$INSTDIR\Data"
RMDir /r "$INSTDIR\res"
; PUDIS Daten installieren
SetOverwrite on
SetOutPath "$INSTDIR"

File /r /x "*.metadata*" "C:\Daten\Diagnose\Rohdaten\Diagnose_Daten\*.*"

WriteINIStr $INSTDIR\DiagnoseSetting.INI Allgemein DatenVersNo "${APPVERSION}"

SectionEnd

Section -FinishSection
WriteRegStr HKLM "Software\${APPNAME}" "DATA_VERSION" "${APPVERSION}"
SectionEnd

; On initialization
Function .onInit
ReadRegStr $DIAGNOSEHOME HKLM "Software\DIAGNOSE" "PATH"
StrCmp $DIAGNOSEHOME "" ENDE DIAGNOSEYES
DIAGNOSEYES:
StrCpy $INSTDIR $DIAGNOSEHOME #
ENDE:
FunctionEnd

; eof

-------------------------------------------------------------------------

You can create an nsis exe, or bat, or vbs script, that writes data to the ini. You can execute this exe/whatever during compilation using !execute or !system. See chapter 5 for details: http://nsis.sourceforge.net/Docs/Chapter5.html


Originally posted by MSG
You can create an nsis exe, or bat, or vbs script, that writes data to the ini. You can execute this exe/whatever during compilation using !execute or !system. See chapter 5 for details: http://nsis.sourceforge.net/Docs/Chapter5.html
Batchfiles nor VBScript/WSH supports INI files.

You can fake a .ini file with !appendfile...

I personally prefer to use AutoIt for compile time scripting when NSIS is impractical or to complicated.