Archive: write user input to file.


write user input to file.
Hi.
I have written this install script. i want to store the information that is entered by the user in a .cfm file, but i don't know how to do this.
at the moment the data is stored in an .ini file and this works fine.

maybe someone of you can help me.


!include "MUI.nsh"

;General

;The name of the installer
Name "..."
;The file to write
OutFile "ac_install.exe"
;Default installation folder
InstallDir "$PROGRAMFILES\ac"
!define VERSION '0.2.3.8'

;--------------------------------
;Interface Settings

!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\head.bmp" ; optional
!define MUI_ABORTWARNING

;--------------------------------
;Pages

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
Page custom config
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
;--------------------------------
;Reserve Files

;These files should be inserted before other files in the data block
;Keep these lines before any File command
;Only for solid compression (by default, solid compression is enabled for BZIP2 and LZMA)

;ReserveFile "mysqlconfig.ini"
;!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
ReserveFile "config.ini"

;--------------------------------
;Languages

!insertmacro MUI_LANGUAGE "German"

;--------------------------------
;Installer Sections

Section "ac" ac

.
.
.

SectionEnd

Section "MYSql" mysql

.
.
.

SectionEnd

Section "Uninstall"

.
.
.

SectionEnd

Function .onInit

InitPluginsDir
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "config.ini"

FunctionEnd

Function config

!insertmacro MUI_HEADER_TEXT "MYSql Konfiguration" ""
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "config.ini"
!insertmacro MUI_INSTALLOPTIONS_READ $0 "config.ini" "Field 4" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $1 "config.ini" "Field 5" "State"
WriteINIStr "$INSTDIR\my.ini" "mysqld" "user" "$0"
WriteINIStr "$INSTDIR\my.ini" "mysqld" "password" "$1"

FunctionEnd

We can't very well tell you without knowing what a .CFM file looks like.

However, if you are referring to a MySQL configuration file (which is .CNF, not .CFM), youcan use the exact same method, simply by replacing the my.ini filename with my.cnf. The files are identical in structure.


.cfm is from macromedia coldfusion.
file looks for example like:

..
<cfscript>

.
.
.....content

</cfscript>
..


the installer should only set a variable (like: username="test" or password="123") in the .cfm file like it can do it in an ini file.

with the write ini function i can only write a file that looks like this.
[cfscript]

.
.
.....content

[/cfscript]


Well, an ugly workaround could be to use of the many find and replace in files functions to replace the <cfscript> with [cfscript], do an ini write, then replace with <cfscript>.