Is it possible to write a custom action using WIX that runs as an administrator that will also have access to the session variables?

StackOverflow https://stackoverflow.com/questions/22255893

  •  11-06-2023
  •  | 
  •  

Question

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?

Était-ce utile?

La solution

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/

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top