How to set a check box to "unchecked" from the msiexec command line? - wix

I have an msi (authored with WIX) that has a check box bound to a custom property (call it MY_PROPERTY). I would like to run this msi from the command line, specifying 0 (unchecked) or 1 (checked) for this property. My script will determine the appropriate value (based on the environment) and inject that value into the msiexec command line. My command line looks something like this:
msiexec /i my_installer.msi MY_PROPERTY=$value
Where $value is 1 or 0, depending on the environment. The problem is that no matter what value I supply for MY_PROPERTY at the command line, the check box is always checked (and the property will always be set to 1). The only way to make the checkbox unchecked is to not specify the property (leave it undefined). It should be noted that this behavior occurs regardless of whether or not the UI is showing (adding "/quiet" to the above command line doesn't change this behavior).
This msdn post seems to indicate that this is a known "bug" in windows installer (or more accurately, whatever authoring system wrote the msi). A post-build msi hack is proposed as the solution. I'm wondering if anyone has encountered this issue and come up with a better workaround/solution. Thanks!
Update
I see three solutions to this problem:
From #Damien, have the wrapper script not pass the property to msiexec when its value is 0. This makes the script more complex and would probably prevent me from being able to override the value of a check box that defaults to "checked".
From #Michael Urman, add a custom action that clears the property if its value is zero. This makes the msi more complex, and I would have to add such a custom action for every check box in the UI.
Another idea is to simply disallow the use of check boxes in our msi installers, and use radio boxes or drop-downs for "true/false" questions instead. While this restricts the UI options for our installers, it woudl allow the wrapper scripts to remain simple, and does not require custom actions to "hack" the properties.
I'm currently leaning towards option 3, although option 1 is probably the best answer to my original question. Any thoughts?

This is how it is "supposed" to work - basically, the property doesn't exist until a user checks the checkbox, then it is "set" (exists). So if you want to do a custom action when a checkbox is checked, you test for the existence of the property as a condition for running the custom action, instead of checking for the value that the custom prop is set to.
I think the best way to handle this from the command line is what you have already mentioned: if you want the checkbox to be selected, specifiy the custom prop on the command line, otherwise, don't and the checkbox will not be selected.

As you've discovered, checkboxes are true (checked) when the property is defined (non-blank) and false (unchecked) when the property is undefined (blank). It sounds like you need to convert an environment 1 or 0 string to a checkbox true/false, where the 1 or 0 is passed in at the command line. Try using a set-property custom action that sets your property to {} (blank) with a condition of when the property is already "0". Schedule it early in both the Install UI and Install Execute sequences.
Late Update: Regarding the need for multiple custom actions to handle this for multiple checkboxes, you have a choice. You can either create multiple set-property actions (benefit: easy to tell what they're doing; cost: many of them), or you can create a single code-based custom action which walks the Checkbox table for a list of properties to convert from 0 to blank (benefit: one action; cost: poorly documented, custom code). A secondary advantage to the latter approach is that you can handle unusual Value settings, such a check box that should set the property to 0 when checked.

Related

WIZ how to skip custom action from executing from parameters while installing msi through command line.?

i have sucessfully installed my msi in silent mode using the following command. msiexec /i mysetup.msi /qn. Also, i have a custom action in my installsequence which is a gui for some configuration. And i dont want that gui appears while installing in silent/command line...
If running in completely silent mode, the "UILevel" property will be equal to 2. Check out this reference for the different levels of UI.
To apply it to your WIX project, in the Sequence you're running the Custom Action, add a condition for the property so your EXE isn't run if that is true. Something like this:
<Custom Action="CA_GUIConfig" After="SetUILEVEL">Not UILevel="2"</Custom>
It may be that the property you need to use in your condition is CLIENTUILEVEL, but it's UILevel that's being checked in my custom code (it's been 10 years since I wrote it, so I'm not exactly clear now). Between either of those 2 properties, I think you'll get it.

KDE Spectacle includeMousePointer on rectangular

The KDE Daemon global shortcuts allow to choose a shortcut for Take Rectangular Region Screenshot, it defaults to Meta+Shift+PrtScr.
However that takes a screenshot with the mouse pointer, how do I disable that?
When I open Spectacle, the includeMousePointer is not checked, so apparently that's a different setting.
Apparently this commit seems to say it's possible to do so but I don't know how.
If you press the hotkey, a D-Bus command is invoked. These commands accept arguments instead of looking at configuration files for maximum flexibility.
The actual D-Bus command that you would need to invoke is:
qdbus org.kde.Spectacle / org.kde.Spectacle.RectangularRegion false
The argument for this RectangularRegion method indicates the value for includeMousePointer. The commit you referenced indeed makes the default hotkey action call this with a true argument instead of false.
If you want to change the default, edit spectacle.khotkeys file in your system. Locate the [Data_1_4Actions0] section, and change Arguments=true to Arguments=false. The result should look like this:
[Data_1_4Actions0]
Arguments=false
Call=RectangularRegion
RemoteApp=org.kde.Spectacle
RemoteObj=/
Type=DBUS
It might be required to restart your session after changing this.

Auto select License Agreement checkbox (or hide it)

I made an installer using wix burn.
I used the standard bootstrapper with Hyperlink license theme.
I don't want to display the EULA checkbox on upgrades. Once accepted one time, I don't want to show it again, or at least auto select it.
To achieve that, I customized the bafunctions.dll and wrote some code in OnDetect(). After a given condition is match, I set the variable EulaAcceptCheckbox = 1. I know that this is the variable name corresponding to the EULA checkbox because I inspected the log of the installer before making this changes.
After making all the modifications, I know my logic is working because I see the following lines in the log:
[1510:1410][2015-11-17T19:01:04]i000: Running detect complete BA function
[1510:1410][2015-11-17T19:01:04]i000: Setting numeric variable 'EulaAcceptCheckbox' to value 1
But the checkbox is not displayed as checked. I tried to set 'EulaAcceptCheckbox' in OnDetect() and also in OnDetectComplete(): no luck.
I also tried to set LicenseUrl="" and WixStdbaLicenseUrl="" but that does not work either.
I have already used bafunctions.dll to do some checkbox customization in another installer. It seems not to work with the EULA checkbox only. What's wrong with my approach?
There seems to be no solution for this.

Can I set a breakpoint condition over entire form?

When running a program I need to see every time a certain button is disabled and step through the code at that point.
If I set a breakpoint with a condition
(ex: only hit when button1.enabled=false) it will only hit in that specific place.
Is it possible to set a breakpoint on the entire program so that i can see when a condition changes across many forms and locations?
You can't set one breakpoint and have it apply to every line of the file, but you can set a breakpoint on the setter of Enabled and then filter it to a specific filter condition. That would give you the desired result. (Note, you might need to turn off "Just my code", see this question for more info)
Set a breakpoint using the "New Breakpoint At Function" as described here, though in Visual Studio 2013, I seem to need to use a slightly different notation:
Then set the breakpoint to funtion:
System.Windows.Forms.Control.Enabled
in C# or for VB.NET:
System.Windows.Forms.Control.set_Enabled(bool)
(You seem to need to use the class that actually defines the property, which in case of the Button class' Enabled property, is the Control class the Button inherits from.
Ignore the warning about it not being able to find the function (it does that for properties somehow), or uncheck the Intellisense lookup.
Now look up the breakpoint in the Breakpoints list and customize the condition so it breaks on the right button
Use the Name property (or any other filter that makes the breakpoint unique) to trigger when you need it to:
When it breaks, it will break in the sources of Control (if you have Framework Source Stepping enabled), which may be confusing. Use the Stack Trace window to find the location where the method was invoked exactly.
Another way of setting the breakpoint is through the Stacktrace window. Set a breakpoint on any line that has your property of interest on it. Launch the debugger and make it break on that line, now use "Step into Specific" to step into the property that you want to break on.
Use the "Stack" window to generate the breakpoint for you:
Since in your case you're looking to break on a function from the Microsoft .NET framework, there is another way. Enabled Framework Source Stepping.
Open the Visual Studio Debugger options and enable "Framework Source Stepping" and disable "Just My Code".
Then enable the Microsoft Symbol Servers in as instructed. Now load up your application under the debugger and wait for the symbol files to be downloaded.
set a break point anywhere in your code that is somehow related to System.Windows.Forms (The constructor of your MainForm for example) and rightclick any function from the "System.Windows.Forms" assembly to load the symbols for that assembly. This will allow you to step into the "Enabled" property and set a break point there.
A full tutorial can be found here:
http://blogs.msdn.com/b/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code.aspx

WIX: how to specify different text on exit dialog for repair and remove?

I'm using WIX 3.0
After I install my product, I can run installer again and remove or repair my product.
How to specify different text on exit dialog for repair and remove?
I used "Installed" property, but it has the same value for repair and remove
Do you have any ideas?
Thanks in advance
You'll have to modify the ExitDialog.wxs for this (taking it from WiX sources and including to your project).
Take ProgressDlg.wxs as an example. It contains several pairs of controls, prefixed with 'Text' and 'Title', for instance 'TextInstalling' and 'TitleInstalling'. These pairs of controls are located at the same positions on a dialog, but are conditioned differently. For instance, 'TextRemoving' and 'TitleRemoving' are shown when WixUI_InstallMode='Remove'. Hence, setting WixUI_InstallMode to 'Remove' at the beginning of uninstall shows "Removing files", etc. on a progress dialog.
You can use this technique for other dialogs as well.
Thanks for update, Yan.
My problem was not how to change some text, but how to know what action was performed, remove or repair.
I don't know if this is good solution, but I used custom action and set the all text I need in the properties. The custom action runs with condition $MyInstalledComponent=2, which means that component is removed and is TRUE only on remove, but not on repair