1

I try to create a installer that has the need to create a file in the programme folder after Installation. For doing so, I have created a custom action, but I now have the following problem:

In order to write the file, I need to know the installation directory from session["INSTALLDIR"], which is only available if the action is executed "immediate".

However, if i run "immediate" after "install files", the target directory does not yet exist. If I run "deferred", it exists, but i cannot access session["INSTALLDIR"].

If I run "immediate" after "InstallFinalize", I can get the variable and the directory exists, but I am not elevated and hence not allowed to write the file.

What is the correct combination for writing a file to the installation directory?

2
  • 1
    What kind of file is it? Commented Jul 17, 2014 at 18:40
  • It is actually an XML configuration file - and I already found out about util:XmlFile ;-) +1 for having the right thought... Commented Jul 17, 2014 at 18:45

2 Answers 2

2

You need to use CustomActionData to access property values from a deferred CA. You need something like this

or

another answer

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks - if you are new to WiX, it is difficult to find the right question to put into a search engine...
1

Beyond using a built in extension for custom actions instead of writing your own, the next level would be how can I move complexity / custom actions out of the installer?

One thought is to write it to the registry instead. Another thought is for the application reading the value to be able to determine installation directory on it's own. One possibility is reflection to get the location another possibility is to query the MSI API for where the product is installed.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.