Dennis Meissel
Dennis Meissel

Reputation: 2503

Create INI file if not exist and write a value

I copy an INI-file from {src} to {app} during the installation with use of the external flag, then I add a key to that file.

If the file does not exist in {src}, it should be created (then a key should be added) in the {app}.

Is it possible to "Create if not exist" inside the [Files] or [INI] or I definitely have to do it in the code-section?

Upvotes: 1

Views: 885

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202494

[INI] section automatically creates the INI file, if it does not exist yet. So you have no problem there.

For [Files] section, see Install only if external file exists.


So in the end, your script should be as simple as:

[Files]
Source: "{src}\MyProg.ini"; DestDir: "{app}"; \
    flags: external skipifsourcedoesntexist

[INI]
Filename: "{app}\MyProg.ini"; Section: "Section"; Key: "Key"; String: "Value"

Upvotes: 1

Related Questions