0

I am trying to use the Inno Setup installation dialog box, during installation to update a few configuration files within my installed files. I managed to create a dialog box for user input of the IP address. How do I capture the IP address entered, then use it for updating the configuration files? The following are an extraction of the code:

#define MyAppName "My Program"
#define MyAppVersion "1"
#define MyAppExeName "MyProg.exe"

[Setup]
.......

;;Zip files to be included in the setup
#define ISSI_Unzip1 "C:\Program Files (x86)\release.zip"
#define ISSI_UnZipDir1 "C:\Program Files (x86)\....."
;;ISSI Include
#define ISSI_IncludePath "C:\ISSI"  
#include ISSI_IncludePath+"\_issi.isi"

....
[Files]
Source: "C:\Program Files (x86)\Inno Setup 5   
\Examples\MyProg.exe";DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Program Files (x86)\release.zip";      `DestDir: "{#ISSI_UnZipDir1}";     `
Flags: ignoreversion deleteafterinstall onlyifdoesntexist
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
Source:"C:\ISSI\_issi.isi";DestDir: "{tmp}"; Flags:deleteafterinstall 

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent` 
Filename: "{tmp}\_issi.isi";Parameters:"x ""{tmp}\release.zip""     `-o""{#ISSI_UnZipDir1}";Check: InitializeSetup(); Flags: runhidden runascurrentuser shellexec;`

[Code]
function httpdCheckedResult:boolean;

begin
  result := FileExists('{#ISSI_UnZipDir1}\release\Apache24\bin\httpd.exe');
end;


function tftpd64CheckedResult:boolean;

begin
  result := FileExists('{#ISSI_UnZipDir1}\release\tftpd64\tftpd64.exe');
end;

var 
 ServerPage: TInputQueryWizardPage;
 ipaddress: String;

Procedure InitializeWizard();
begin  
ServerPage:= CreateInputQueryPage(wpWelcome, 'Network   Interface                Address','IP Address?', 'Please specify the designated network interface IP Address,then click Next.');

//Add item (False means it's not a password edit) 
ServerPage.Add('IPAddress of Configuration file:',False);

//Set initial values (optional)
ServerPage.Values[0] := ExpandConstant('{param:ipaddress}');

//Read values into variables
ipaddress := ServerPage.Values[0];
end;

function Getipaddress(Param: String): String;
begin 
   if Param = 'ipaddress' then 
    Result := ServerPage.Values[0]
   else  
    MsgBox('Please enter ip address.', mbInformation, MB_OK);
end;

 function InitializeSetup(): Boolean;

   `begin`                                                                                                    
 begin
    if httpdCheckedResult()  then
         begin
         MsgBox('The httpd application is installed already.'mbInformation, MB_OK);
     Result := False;     
     end
if tftpd64CheckedResult() then
     begin                                           
     MsgBox('The tftpd application is installed already.', mbInformation, MB_OK);
     Result := False;     
     end
 end

  begin
    if not httpdCheckedResult() or not tftpd64CheckedResult() then  
    Result := True;
  end;

 end;

--------------------------------UNQUOTE-------------------------------------- The following are the contents of the respective configuration files I was trying to update the IP address:

File1:

#!ipxe

# Name: boot.ipxe.cfg
# Version: 1.3.0
# Date: 09 JUN 2015
# Description: Global variables declaration for all iPXE scripts
### 

# Base URL used to resolve most other resources
# Should always end with a slash
set boot-url http://<IP ADDRESS HERE>/

# ESXi install media base
set esxi-base-url ${boot-url}esxi

# RHEL install media base
set rhel-base-url ${boot-url}rhel

# where the current release files are located
set current ${boot-url}current/ 

# where the kickstart configs are located
set ks-dir ${current}ks/

# where additional files to be transfered using wget
set files-dir ${current}files/


# OPTIONAL: Relative directory to boot.ipxe used to
# override boot script for specific clients
set boot-dir boot/

# REQUIRED: Absolute URL to the menu script, used by boot.ipxe
# and commonly used at the end of simple override scripts
# in ${boot-dir}.
#set uefi-menu-url menuuefi.ipxe
set menu-url menu.ipxe

# Set netif mac
 set boot-mac ${netX/mac}
 set boot-mac-hyp ${netX/mac:hexhyp}

Configuration File2 :

bootstate=0
title=Loading ESXi installer
timeout=3
prefix=http://<IP ADDRESS>/esxi65
kernel=tboot.b00
kernelopt=runweasel formatwithmbr
modules=b.b00 --- jumpstrt.gz --- useropts.gz --- features.gz --- k.b00 ---     chardevs.b00 --- a.b00 --- user.b00 --- ......
...
build=updated=0
  • I'm closing your question, until you tell us something about your "configuration file". There are zillions of format of configuration files. Anyway, major formats are covered by existing questions already. – Martin Prikryl Mar 19 '18 at 06:36
  • It is a .CFG file that can be opened by notepad for windows platform. – MightStackier Mar 19 '18 at 08:53
  • That does not tell us anything, only that it's a text file (what most configuration file are). – Martin Prikryl Mar 19 '18 at 10:18
  • A few files. One is a kickstart file for an esxi server image to be installed via a RHEL based server, i.e. a boot file.The other is a tftp boot.ipxe file to facilitate the same operation. Hope that answers the question. :) – MightStackier Mar 20 '18 at 02:42
  • Show us the files. Show us what exact change you want to do in the files. – Martin Prikryl Mar 20 '18 at 06:13
  • Included in the edited post. Just need to update IP address based on user input. – MightStackier Mar 20 '18 at 07:57
  • This is already covered by the first duplicate question: [Replace placeholder in an installed text file with input entered by user](https://stackoverflow.com/q/45289100/850848). – Martin Prikryl Mar 20 '18 at 08:09
  • I encountered a runtime error: "an attempt was made to access WizardForm before it has been created." Is there any way I can run the InitializeWizard(), let it appear without affecting the InitializeSetup()? – MightStackier Mar 22 '18 at 07:48
  • I do not understand your question. If you have a problem, post a separate question with [mcve]. This is Q&A site, not a chat! – Martin Prikryl Mar 22 '18 at 07:53

0 Answers0