使用Innosetup更新配置文件中的IP地址

时间:2018-03-19 05:17:31

标签: inno-setup configuration-files

我正在尝试使用Inno安装程序安装对话框,在安装过程中更新我安装的文件中的一些配置文件。我设法创建了一个用户输入IP地址的对话框。 如何捕获输入的IP地址,然后使用它来更新配置文件?以下是代码的提取:

#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;

--------------------------------引文结束-------------- ------------------------ 以下是我尝试更新IP地址的相应配置文件的内容:

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}

配置文件2:

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

0 个答案:

没有答案