SirNoob
Posts: 4
Joined: Tue May 06, 2014 11:20 am

Edit .ini File during instalation

Hi
i want create a dialog wich text boxes to change values in a .ini file.

example : in the ini file i have the section "Socket"
with the value ip=192.168.1.1"
now i want a dialog who i can change the value "192.168.1.1" to something else.
But it doesent work.
I hope anyone can help me to find a solution.

Regards
SirNoob
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Edit .ini File during instalation

Hello and welcome to Advanced Installer forums,

Thank you for your interest in Advanced Installer.

In order to achieve what you want you can use our INI files support. For example you can go in "Dialogs" page and add an edit box control associated with an IP_PROP public property. Then, you can go in "Files and Folders" page and create from scratch your INI file (using [New INI file] toolbar button) or you can import the INI file (using the {Import Files -> Import INI] button). Finally you can edit the "ip" entry value of your INI file to use the IP_PROP property.

Also, I've attached a sample created with version 11.1 of Advanced Installer, which implements a similar scenario.
sample.zip
(3.09 KiB) Downloaded 690 times
Please keep in mind that you need at least an "Enterprise" project type in order to implement this scenario.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
SirNoob
Posts: 4
Joined: Tue May 06, 2014 11:20 am

Re: Edit .ini File during instalation

Ah thank you that’s very great.
Now I have 2 more Questions:
How can I make the Text box “required” and is it possible to make that value “required” for a silent (/quiet) installation?!

Regards
SirNoob
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Edit .ini File during instalation

Hello,

In order to achieve what you want you can proceed like this:
- go to "Dialogs" page, select the dialog containing the IP edit text and on the [Next] button add the following published event:
  • Control Event: Display a specific child dialog
    Argument: <New Dialog>
    Condition: IP_PROP = ""
- move the above published event as the last event in the "Published Events" list
- go to "Custom Actions" page and add an "Execute an inline script code" custom action with sequence, scheduled after "Install Execution Stage -> Paths Resolution" actions group, like this:
  • Code:
    MsgBox "The installation failed because you haven't set the IP_PROP property from command line"
    WScript.Quit(3)

    Condition: IP_PROP = ""
- also, the above custom action should be configured to run only on install
- build and run your project

If you have any questions let us know.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
SirNoob
Posts: 4
Joined: Tue May 06, 2014 11:20 am

Re: Edit .ini File during instalation

Hi thank you for your Help,
but the instruction are not working (i use version 11.1 of ADvanced Installer)
Or i just make something wrong ^^
Can you give me a sample project, please?

Regards
SirNoob
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Edit .ini File during instalation

Hello,

I've attached a sample file created with AI 11.1 which implements this scenario.
sample.zip
(3.4 KiB) Downloaded 498 times
If you have any questions let us know.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
congnt92
Posts: 57
Joined: Wed Apr 16, 2014 7:53 am

Re: Edit .ini File during instalation

Hi Daniel, SirNoob.
My project will add some lines to boot.ini file on Windows XP. And I using "add .ini file" at " Files and folders" page to archive it.
Original boot.ini

Code: Select all

[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect
My app will check the existence of boot.ini, if it exist, my app will add

Code: Select all

C:\grldr="Grub4DOS"
under [operating systems] entry.
If boot.ini does not exist, boot.ini will be created by my app.

Code: Select all

[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect
C:\grldr="Grub4DOS"
But if my app run on computer which run windows 7, it create boot.ini, too. Boot.ini is not need for windows 7. So, how can I solve this problem? Thanks
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Edit .ini File during instalation

Hello,

In order to install your "boot.ini" file only on Windows XP OSes, then you should condition accordingly its associated component. Here are the steps to proceed:
- go to "Files and Folders" page and from the context menu of your "boot.ini" file choose "Go To Component" option
- in the "Condition" field of the selected component from "Organization" page add the following condition:

Code: Select all

VersionNT=501
- build and run your project

Also, you can take a look on our "Install resources based on the OS version" article.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
SirNoob
Posts: 4
Joined: Tue May 06, 2014 11:20 am

Re: Edit .ini File during instalation

Hello
thank you very much for your example file.

I have built my own project with your help but when i make a "cmd quiet" instalation always the msgbox appears .

Can you please check the file for mistakes?

http://www.mediafire.com/download/i64e4 ... Sample.rar

Regards
Robert
congnt92
Posts: 57
Joined: Wed Apr 16, 2014 7:53 am

Re: Edit .ini File during instalation

Hi Daniel, SirNoob
Thanks for your help, Daniel. Before I ask you, I tried method which you suggest, but if I do that, registry will be not add if my app was run on Windows 7.
Attachments
Capture.PNG
Capture.PNG (39.26 KiB) Viewed 10770 times
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Edit .ini File during instalation

Hello Robert and congnt92,

@SirNoob: This happens because you have used a private property (Ip_Test) instead of a public one. Please keep in mind that only public properties can be set from command line (e.g. when trying to install using a silent commandline). Therefore, you should rename your "Ip_Test" private property to a public property name (e.g. "IP_TEST"). I've edited and attached your sample project.
sample.zip
(3.34 KiB) Downloaded 1034 times
@congnt92: Indeed in this case all resources resinding under the related component will not be installed. However, in order to condition only the installation of your INI file you can add into your project a dummy resource (e.g. a file or a registry) and then, using drag and drop, move all of your INI values under the component of the dummy resource.

If you have any questions let us know.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
congnt92
Posts: 57
Joined: Wed Apr 16, 2014 7:53 am

Re: Edit .ini File during instalation

Hi Daniel, SirNoob
That's a good idea!! I follow your guide and it work for me. Thanks so much, Daniel.
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Edit .ini File during instalation

You're welcome.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”