akundi
Posts: 5
Joined: Fri Sep 02, 2005 1:00 pm

update a registry value

I would like to update the value in registry item based on the previous value of that item.I need to first read the registry for that value and update it .How do I do it using custom vbscript?
Mike
Posts: 292
Joined: Wed Jun 01, 2005 10:50 am
Location: Craiova, Romania
Contact: Website

Hi,

You can easily achieve this with VBScript. There are available two methods for reading / writing into registry: RegWrite and RegRead.

The following code, for example, writes in the HKLM/software a key with the product name and, inside it, a value which contains "1".

Code: Select all

Function WriteReg()

Dim objShell 
Set objShell = CreateObject("WScript.Shell")
 
Dim pathToKey, productName

pathToKey =  "HKLM\Software\"
productName = Session.Property("ProductName")

objShell.RegWrite pathToKey + productName + "\MyKey", 1, "REG_BINARY"

MsGBox("Written 1 in "+pathToKey + productName + "\MyKey")

End Function
In your case, you should read the old value, modify it according to your needs, and then write it back.

You must enter this code in a VBS file and you use it as an attached custom action. Don't forget to enter the name of the function in the "Function Name" text field.

For more information on this topic please visit:
http://msdn.microsoft.com/library/defau ... gwrite.asp
Mihai Bobaru
Advanced Installer Team
http://www.advancedinstaller.com
shayeh
Posts: 8
Joined: Mon Feb 27, 2006 6:56 pm

Advanced Installer User Guide wrote: How do I update an existing registry value?
Answer
Go to the Registry page, by selecting it in the left-side panel. Select the Registry hive tree by clicking in it.

Use the [ New Key ] toolbar button to recreate the required registry path.

Use the [ New Value ] toolbar button to create the required registry value.

If the registry keys and the value already exist, the value's data will be modified. If not, the keys and the value will be created.
After app. removing the updated registry value will be removed, and user's system will die.
ciprian
Posts: 259
Joined: Thu Jul 14, 2005 12:56 pm
Location: Craiova, Romania
Contact: Website

Hi,

When you are using the method described in the User Guide for updating a registry value, that value is practically overwritten. That is why upon uninstall it is deleted.

If you want to revert to the old value during the uninstall process I suggest using two custom actions. One custom action is executed when the package is installed and updates the registry value. The other is executed on uninstall and reverts the registry entry to the old value.

More details on how to set up these custom actions you can find in the above post.

All the best,
Ciprian
Ciprian Burca
Advanced Installer Team
http://www.advancedinstaller.com

Return to “Feature Requests”