/build/static/layout/Breadcrumb_cap_w.png

Wix: Write a registry Entry during uninstallation

Hi Guys,

I am using Wix to write my MSIs.

I need to update a registry entry while uninstalling my application, does anybody know how this could be done.

Thanks
Nixu [/align]

0 Comments   [ + ] Show comments

Answers (18)

Posted by: axsysbabu 15 years ago
Orange Belt
0
hi nix,
run the install script ....... or create run the batch files


regards,
babu.
Posted by: anonymous_9363 15 years ago
Red Belt
0
Axsys, do you know what Wix is? This kind of response really isn't helpful.
Posted by: AngelD 15 years ago
Red Belt
0
How about authoring a custom action with a condition of REMOVE="ALL" to write the registry?
Posted by: anonymous_9363 15 years ago
Red Belt
0
Kim, The OP is asking how to do that with Wix. My suspicion is that nothing short of showing the entire XML extract will do...
Posted by: nixu 15 years ago
Yellow Belt
0
Hi there,

The problem is that I need to modify a registry entry under the LocalMachine.
If i try to modify that key from a custom action and the user does not have rights to modify that part of the registry the Custom action fails.

This is why I need to modify the registry from wix.

Nixu
Posted by: anonymous_9363 15 years ago
Red Belt
0
How much time would have been saved if you had stated the problem properly? Using Wix will make no difference whatsoever, since Wix is simply a technology to create MSIs.

You need a Custom Action to permission the key above which YOUR key needs to be created, calling out to SetACL, SubInACL or whatever your preferred permissioning tool is.
Posted by: nixu 15 years ago
Yellow Belt
0
Hi VBScab

I am Creating MSIs to install software, and these MSI are written using WIX, So YES i am using the right tool.

To set the required ACL, you need to have permissions first, and not all users have such permissions, or else you can impersonate an admin user but you need to supply his credentials.

Using wix's basic registry stuff i am able to write under the LocalMachine during installation, but I just got stuck in writing during uninstallation.

Any help??

Nixu
Posted by: AngelD 15 years ago
Red Belt
0
Hi Nixu,

You need to sequence the custom ation in Deferred execution.
Posted by: nixu 15 years ago
Yellow Belt
0
I will give it a try using the Deferred execution.

Do you think i need to set the Impersonate to No too?

Nixu
Posted by: anonymous_9363 15 years ago
Red Belt
0
ORIGINAL: nixu
Do you think i need to set the Impersonate to No too?
I don't think there are many Wix experts online today so I'd suggest that it wouldn't be overly taxing to try both.
Posted by: AngelD 15 years ago
Red Belt
0
You should set the msidbCustomActionTypeNoImpersonate attribute bit so the custom action is executed under the system context and not the user who launched the installation.

So yes, set it to no.
Posted by: jmcfadyen 15 years ago
5th Degree Black Belt
0
[blockquote]
[/blockquote]
Information about registry keys and/or values to be installed is authored in the Registry table. This table is processed by WriteRegistryValues and RemoveRegistryValues standard actions which must be scheduled in the Execute sequence tables.
To remove registry keys and/or values during install users must use RemoveRegistry table. This table is processed by RemoveRegistryValues standard action which must be scheduled in the Execute sequence tables.
Here is the list of columns of the Registry table:




Column name
Description

Registry
Primary key of the record.

Root

The predefined root key for the registry value:

  • default (-1) - Depends on the type of installation:
    • HKCU - for per-user installation.
    • HKLM - for per-machine installation.

  • msidbRegistryRootClassesRoot (0) - HKCR
  • msidbRegistryRootCurrentUser (1) - HKCU
  • msidbRegistryRootLocalMachine (2) - HKLM
  • msidbRegistryRootUsers (3) - HKU


Key

The localizable key for the registry value.

Name

Localizable registry value name. Use Null value to write to the default registry key.

Value

Localized registry value. This field is formatted field.

Component_
External key into the Component table.
To remove registry key on install we need to add record to the RemoveRegistry table:




Column name
Description

RemoveRegistry
Primary key of the record.

Root

The predefined root key for the registry value:

  • default (-1) - Depends on the type of installation:
    • HKCU - for per-user installation.
    • HKLM - for per-machine installation.

  • msidbRegistryRootClassesRoot (0) - HKCR
  • msidbRegistryRootCurrentUser (1) - HKCU
  • msidbRegistryRootLocalMachine (2) - HKLM
  • msidbRegistryRootUsers (3) - HKU


Key
The localizable key for the registry value.

Name
The localizable registry value name. If registry key is to be deleted, this column must contain minus sign (-).

Component_
External key into the Component table.
[blockquote]
What we can do with the registry[/blockquote]
These are the options we have when we install/delete registry key or value:

  • For registry keys:[/align]

    • Create the key on install.[/align]

    • Delete the key on uninstall.[/align]

    • Create the key on install and delete it on uninstall.[/align]

    • Delete the key on install.[/align]


  • For registry values:[/align]

    • Create a binary (REG_BINARY) value.[/align]

    • Create an integer (REG_DWORD) value.[/align]

    • Create a string (REG_SZ) value.[/align]

    • Create an expandable string (REG_EXPAND_SZ) value.[/align]

    • Create a Null terminated list of strings (REG_MULTI_SZ) value:[/align]

      • New string can override existing string.[/align]

      • New string can be appended to existing string.[/align]

      • New string can be prepended to existing string.[/align]

In MSI, prefixes to the Name column and prefixes and suffixes to the Value column are used to indicate the action to be performed. In Wix, elements <Registry> and <RegistryValue> are used for that purpose.
[blockquote]
How it translates to WiX?[/blockquote]
To create/delete registry keys:




Registry table
RemoveRegistry table
Registry element's
attribute
Description

Name
Value
Name


+
Null

Action="createKey"
On install, the key will be created if it is absent.

-
Null

Action="removeKeyOnUninstall"
On uninstall, the key will be deleted, including all its values and subkeys.

*
Null

Action="createKeyAndRemoveKeyOnUninstall"
The key will be created on install and deleted on uninstall.



-
Action="removeKeyOnInstall"
On install, the key will be deleted if present.
Prefixes and suffixes of the value in the Value column of the Registry table determine type of data stored in the registry:




Value column
Registry element's
attribute
Description

#x
Type="binary"
Hexadecimal value stored as binary data (REG_BINARY).

#%
Type="expandable"
Expandable string (REG_EXPAND_SZ).

#
Type="integer"
Integer value (REG_DWORD).

Contains [~] anywhere
Type="multiString"
List of strings (REG_MULTI_SZ).

Starts with two or more # or does not contain [~]
Type="string"
String (REG_SZ).
[blockquote]
Examples[/blockquote]

  • Create a registry key on install and remove it on uninstall:[/align]

<Registry Id="TestKey"
Root="HKLM"
Key="SOFTWARE\ACME Corp"
Action="createKeyAndRemoveKeyOnUninstall" />

  • Remove a registry key on install:[/align]

<Registry Id="TestKey"
Root="HKLM"
Key="SOFTWARE\ACME Corp"
Action="removeKeyOnInstall" />
[blockquote]
If you only remove registry key and do not create new ones, make sure you schedule RemoveRegistryValues standard action in the Execute sequence table. For example:[/blockquote]
<InstallExecuteSequence>
<RemoveRegistryValues />
</InstallExecuteSequence>


  • Create a registry key with default value:[/align]
[/align] <Registry Id="TestKey"
Root="HKLM"
Key="SOFTWARE\ACME Corp"
Action="createKeyAndRemoveKeyOnUninstall">
<Registry Id="DefaultValue"
Action="write"
Type="integer"
Value="123" />
</Registry>

  • Create a registry key with the string value:[/align]

<Registry Id="TestKey"
Root="HKLM"
Key="SOFTWARE\ACME Corp"
Action="createKeyAndRemoveKeyOnUninstall">
<Registry Id="TestValue"
Name="TestValue"
Action="write"
Value="123"
Type="string" />
</Registry>


  • On install, remove existing value of the registry key:[/align]

<Registry Id="TestKey"
Root="HKLM"
Key="SOFTWARE\ACME Corp"
Action="createKey">
<Registry Id="TestValue"
Name="TestValue"
Action="remove" />
</Registry>


  • Create a multi-string value:[/align]

<Registry Id="TestKey"
Root="HKLM"
Key="SOFTWARE\ACME Corp"
Action="createKeyAndRemoveKeyOnUninstall">
<Registry Id="TestValue"
Name="TestValue"
Type="multiString"
Action="append">
<RegistryValue>123</RegistryValue>
<RegistryValue>456</RegistryValue>
<RegistryValue>789</RegistryValue>
</Registry>
</Registry>

  • Create a key with sub-key: [/align]

<Registry Id="TestKey"
Root="HKLM"
Key="SOFTWARE\ACME Corp"
Action="createKeyAndRemoveKeyOnUninstall">
<Registry Id="SubKey"
Key="SubKey"
Action="createKeyAndRemoveKeyOnUninstall" />
</Registry>[/align][/align]
Posted by: jmcfadyen 15 years ago
5th Degree Black Belt
0
sorry formatting got dropped.
Posted by: jib 15 years ago
Purple Belt
0
ORIGINAL: jmcfadyen

sorry formatting got dropped.



nah dont be, the OP should have enough info to solve this question ..

Looking forward to your blogposts about WiX, John! :-)
Posted by: AngelD 15 years ago
Red Belt
0
Very informative John!

However the OP is trying to modify the registry during uninstall so your suggestion will not be usable this time.
Posted by: anonymous_9363 15 years ago
Red Belt
0
If the OP had any gumption or ambition beyond that of requiring others to do the work for him, he might go out on a limb and replace
Root="HKLM"
Key="SOFTWARE\ACME Corp"
Action="removeKeyOnInstall" />

with
<Registry Id="TestKey"
Root="HKLM"
Key="SOFTWARE\ACME Corp"
Action="removeKeyOnUninstall" />
Posted by: AngelD 15 years ago
Red Belt
0
ORIGINAL: nixu

Hi Guys,

I am using Wix to write my MSIs.

I need to update a registry entry while uninstalling my application, does anybody know how this could be done.

Thanks
Nixu [/align]

Sorry but can't see how he can update (modify) a registry entry during uninstall with either the Registry nor RemoveRegistry table during uninstall if the OP didn't mean remove instead of update.
Posted by: jmcfadyen 15 years ago
5th Degree Black Belt
0
jib,

I will be starting on basic Wix this week... as you can see I have some info together already.

John
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ