1

I have created a WIX installer that installs a windows service into the ProgramFilesFolder. Once installed, I need to be able to modify the app.config to point several entries to the installation folder. Since the installed service could be installed on both x86 and x64 machines I don't know at compile time if the correct path is "\Program Files" or "\Program Files (x86)", nor can I guarantee that the Program Files folder will be on C:.

The custom action that I've created modifies the installed app.config to point to the correct folder using the data available in the INSTALLFOLDER session variable. This works great when I run the installer from an elevated command prompt, but I'm trying to make things simpler on my users.

Unfortunately, the app.config is for a windows service, and as such the directory that launches the service is \Windows\System32, and not the installed folder, so using a relative path in the app.config won't work.

Is there any way that I can execute the custom action as an administrator while still maintaining access to the session variables, or alternately, some way to make just the value of INSTALLFOLDER available to the custom action?

2
  • Check this answer: stackoverflow.com/a/3925581/1766402 Commented Mar 7, 2014 at 18:48
  • Thanks! This link lead me to the one below which ultimately helped me to solve my problem. Commented Mar 7, 2014 at 19:08

1 Answer 1

3

Unless I'm misunderstanding something, this isn't too complicated.

1) Deferred custom actions run with elevation under the system account and should be able to get to the program files folder.

2) In the deferred custom action use CustomActionData to pass the [INSTALLFOLDER] property into the deferred custom action code, which is the way that deferred CAs get access to properties without the session handle.

This might be relevant:

How to pass CustomActionData to a CustomAction using WiX?

http://sajojacob.com/2008/02/customactiondata-in-wix-with-deferred-custom-actions/

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

1 Comment

Based on the comment above (by @Isaiah4110) I found out about the CustomActionData property (which lead me to your link above), and was able to resolve the problem. Thanks!

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.