I am using WiX and want to know if we can disable a control in a built-in dialog. My requirement is to disable the "Browse" button in the "CustomizeDlg".
-
I'm afraid you'll have to replace the whole CustomizeDlg with your custom one to achieve this. – Oscar Jan 22 '18 at 09:04
-
I suspected that! Is it a good idea to do it? – user3106666 Jan 22 '18 at 09:05
-
It seems the way to go. Grab the source code of the original CustomizeDlg from Fire Giant github page, modify it and include the new dialog in a new custom ui. Remember to add events to show your custom dialog as needed, replacing the calls to the old one. There's a tool called WixEdit wich was helpful for me doing a similar task – Oscar Jan 22 '18 at 09:14
-
Ok Great! Thanks. – user3106666 Jan 22 '18 at 09:24
2 Answers
This became too long for a comment. I might "evolve" it as an answer if we get more information about your scenario. Just a couple of heads-ups for you.
If you are trying to prevent the setup from being installed to a non-standard path, then you should account for the fact that the installation directory can be set at the msiexec.exe
command line when the setup is installed in silent mode. Sample (untested by me - first thing I found :-) ).
I suppose a custom action could be used to abort the setup if it is installed in silent mode to a non-standard path? An immediate mode custom action before InstallInitialize
somewhere I guess, but after costing actions (CostInitialize
, CostFinalize
, FileCost
, InstallValidate
, etc...) - but frankly, why do this? Perhaps you could illuminate your use-case?
Oh, and please don't leave the standard action RemoveExistingProducts
to run before your custom action (in the InstallExecuteSequence
). This would remove the existing, related installation on the box (if any) and then abort the major upgrade operation leaving no install left on the box.
And don't add your custom action to the user interface sequence - there is no need. This sequence is entirely skipped in silent installation mode, and if there is no way to set a custom path in the GUI, it can't be changed there anyway (and the InstallExecuteSequence's custom action would catch any changes should they be set anyway - it will do).

- 39,960
- 25
- 91
- 164
-
Disagreed with the final paragaph for two reasons. First, to avoid a worse user experience, fail as early as you know you know it will happen. Second, nothing prevents passing command line parameters to an install that isn't silent. (Bonus observation: it may be better to just reset the directory if you know what it should be, effectively ignoring any override attempts.) – Michael Urman Jan 23 '18 at 13:58
-
The custom action in InstallExecuteSequence would still abort the install even if TARGETDIR is set at the command line for an interactive setup (non-silent). A proper, "interactive" error message / explanation from a UI custom action may be beneficial though - but strictly speaking not necessary. There are some other issues with regards to conditioning that I should add some heads-ups about though. – Stein Åsmul Jan 23 '18 at 15:47
Per this thread which discusses how to enable the button, what you need to do is the reverse: ensure your Feature
elements do not specify a ConfigurableDirectory
, or that it is not public by using some lowercase letters in the identifier.

- 15,737
- 2
- 28
- 44
-
That's nice and easy - never seen that, it should take care of the GUI-problem entirely? I suppose we still have the command line problem though? All this flexibility in (parts of) MSI seem to cause more problems than benefits. – Stein Åsmul Jan 24 '18 at 03:21
-
If the directory identifier is non-public, then the directory cannot be changed, and your hypothesized scenario won't apply. – Michael Urman Jan 24 '18 at 19:25
-
Public properties can be anywhere in the directory table? And beyond directories set at the command line and feature directories, there are set property custom actions that can also cause weirdness. I toy with these settings as little as possible, so I am not sure exactly what is possible, but flexibility is there (people trying to install directly to C:\ and that kind of unnecessary and error prone stuff). – Stein Åsmul Jan 24 '18 at 19:33
-
You control your directory identifiers, and thus whether the DirProperty name is public. If you choose all non-public nanes then there are no directories that can be changed at run time. Whether that works for your needs depends on your needs. But let's not have a discussion in comments. – Michael Urman Jan 24 '18 at 20:16
-
The [this thread](http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Mondo-UI-browse-button-disabled-td699237.html) link is now dead and not archived by archive.org. [This SO question](https://stackoverflow.com/questions/2357195/wix-disable-directory-browse-button?rq=1) seems to have some related information – iboisver Feb 22 '23 at 22:43