raghu.00a@gmail.com
Posts: 27
Joined: Tue May 10, 2016 11:18 am

Registry Entry for CheckBox is not saved

Hi,

I have a Checkbox in the Exit dialog and want this checkbox value should be saved in registry entry.

I set persistent property of this checkbox, When I unchecked and click on finish, this value is not saved in registry.

Is this the problem of having a checkbox in Exit Dialog?

Please suggest me how to save checkbox value in registry from exit dialog.

Regards
Raghu
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Registry Entry for CheckBox is not saved

Hello Raghu,

The behavior of your project is normal. If the default setting for the checkbox is "Selected : True", the property attached to your checkbox is initialized with the value from "Value" field. Adding the registry keys and values is part of "Add Resources" action group, so before the "ExitDialog" appears, that means any change is made to this property on "ExitDialog" will not be in the Windows Registry.

To store the value of the checkbox that appears on "ExitDialog" in the registry you can use a custom action that writes the value in the registry. The custom action can be called on {Finish] button from "ExitDialog".

To achieve this you must set the following configuration :

1. In order to add to registry a value, you can create a batch file and include it in the project, with the following content :

Code: Select all

REG ADD %1 /v %2 /t %3 /d %4 /f
The arguments are :
  • Path of the key
    Name for the value
    Type of the value
    Data
The "/f" switch is for overwriting the data if the value exists.

2. In the Advanced Installer project you can create in "Install Parameters" page four properties, corresponding to the four arguments – "REG_PATH", "REG_VALUE", "REG_VALUE_TYPE", "REG_DATA".
3. In "Custom Actions" page we add a "Launch file" custom action, without sequence like this :
  • File to launch : [#reg.bat]
    Command line : [REG_PATH] [REG_VALUE] [REG_VALUE_TYPE] [REG_DATA]
    Run as Administrator - checked
4. In "Dialogs" page, on "Finish" button from "ExitDialog" we add two published events :
  • Set installer property value
    Property : REG_DATA
    Argument : [CHECKBOX_1_PROP]
    Condition : CHECKBOX_1_PROP
  • Execute custom action
    Argument : Launch file
The first one set the value of the REG_DATA property with the value of CHECKBOX_1_PROP if this is checked, that's because the batch file will give an error if it doesn't have as argument a value for Data. If the checkbox is unchecked, the registry will store the default value of REG_DATA, the one that you declared above in "Install Parameters" page. The second one launches the file and saves the value to the registry.

You can find attached a sample project which implements these settings.
Reg checkbox.aip
(13.34 KiB) Downloaded 427 times
Should there be any difficulty you encounter implementing something, please do not hesitate to contact me and I will gladly assist.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
raghu.00a@gmail.com
Posts: 27
Joined: Tue May 10, 2016 11:18 am

Re: Registry Entry for CheckBox is not saved

Hi Daniel,

The reg.bat file is missing when I build the attached project. can you give me reg.bat file
I created the bat file with "REG ADD %1 /v %2 /t %3 /d %4 /f" and I added this file to "files and folders" temporary directory.

I built and run the installer, but at the end on clicking the finish button, the cmd.exe window is opened and it continuously displaying REG ADD %1 /v %2 /t %3 /d %4 /f.
and the property is not created in registry.


Please suggest me where to add .bat file in files and Folders?



Regards
Raghu
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Registry Entry for CheckBox is not saved

Hello Raghu,

You can find attached a ZIP archive containing the BAT file. However, please note that the BAT file should not be added as a temporary file in "Files and Folders" page. It should be added as a regular (permanent) one, otherwise the BAT file won't be available at the time custom action runs on "ExitDialog".

If you have any question just let us know.

All the best,
Daniel
Attachments
reg.zip
(179 Bytes) Downloaded 445 times
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
raghu.00a@gmail.com
Posts: 27
Joined: Tue May 10, 2016 11:18 am

Re: Registry Entry for CheckBox is not saved

Hi ,

On clicking finish button, windows command processor dialog is opening. Is there any option to not display this dialog to user?

In registries a value (zero) is saved for key (Checkbox), In place of the name (checkbox) can we give CheckBox_1_prop .
if checkbox is checked or unchecked what values will be saved in registry?

In the Published Events section of the exit dialog you are assigning CheckBox_1_prop to REG_DATA.I want the checkbox state should come from registry for second time install, can you please suggest me how to do this.

can you please tell me difference between the types REZ_SZ and REG_DWORD?

Regards
Raghu
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Registry Entry for CheckBox is not saved

Hello Raghu,
On clicking finish button, windows command processor dialog is opening. Is there any option to not display this dialog to user?
Yes, this is possible. Just go to "Custom Actions" page and check the "Hie program's window" option of the "LaunchFile" custom action.
In registries a value (zero) is saved for key (Checkbox), In place of the name (checkbox) can we give CheckBox_1_prop .
if checkbox is checked or unchecked what values will be saved in registry?
To edit the name of the created registry value just go to "Install Parameters" page and edit the value of the "REG_VALUE" property.
I have created abd attached a new sample (more meningful) which will save the "unchecked" and "checked" value in the registry when the checkbox is unchecked, respectively checked.
In the Published Events section of the exit dialog you are assigning CheckBox_1_prop to REG_DATA.I want the checkbox state should come from registry for second time install, can you please suggest me how to do this.
To do so, you can create a registry value search (i.e. CHECKBOX_STATE) in "Search" page which will search for the related registry value. Then, based on this search result you can set, for instance on the "Init Events" tab of "VerifyDlg" dialog, the CHECKBOX_1_PROP" property to a "checked" value or "{}" value (the latter value means the property is empty, thus the checkbox will be unchecked).

Please take a look at the attached sample.
can you please tell me difference between the types REZ_SZ and REG_DWORD?
The first one accept strings and the second one accept only numbers. Please take a look on the "Registry Value Types" article.

All the best,
Daniel
Attachments
sample.zip
(6.22 KiB) Downloaded 357 times
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”