Is it possible to call installer class on button click in c# not in setup Custom Action?
If the user does not have admin permissions. How can I call the installer class on the button click event which reads from the registry and also write a value to the registry in c#?
Because I am getting an error when the user goes to registration it writes value in registry and the users do not have rights to write to registry. So i know that only the installer class has the right to do that. So ho开发者_如何学Cw can I make this work?
The recommended approach is to use two different custom actions:
- one in the installation UI which reads data (your registry value)
- the other in InstallExecuteSequence (during install) which writes data
This way you shouldn't have permission problems.
There isn't one possibly valid reason to want to do this. Installer class custom actions have no access to the MSI handle. This means they can't get/set properties. The only thing that can be used for is to change the configuration of the machine and it goes against all Windows Installer best practices to do this from within the User Interface Sequence.
The only thing that should be done on a button in the UI is validation processing that must be done before going to the next dialog. An example would be validating user input such as credentials for connecting to a SQL server. The heavy lifting of connecting to the SQL server and doing something with it should be done as deferred custom actions in the execute sequence.
I suggest looking into WiX DTF. This exposes more functionality then Installer class custom actions and allows you to create solutions that follow best practices.
精彩评论