We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

DeadlyDonger
Posts: 19
Joined: Wed Jan 07, 2015 6:44 pm

Change Registry Value at Uninstall

I want to change the value '(default)' in the key: HKEY_CLASSES_ROOT\txtfile\shell\open\command. After uninstalling, regardless of what the value is, I want to change it back to the default value which is: %SystemRoot%\system32\NOTEPAD.EXE %1. How do I achieve this?

If the value is %SystemRoot%\system32\NOTEPAD.EXE %1 which is the default don't do anything, If it is then change it back to it. I don't want to hook this to the Uninstall Cleanup because this shouldn't be something that needs to be kept. Is there a way I can do this with a condition or something at uninstall ONLY.
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Change Registry Value at Uninstall

Hello,

This can be done by using custom actions which backup and restore the registry entry. Please take a look on the Return orginal registry value if MSI is uninstalled forum thread which debates a similar subject.

You can also take a look on the Options to integrate and debug custom actions article which may be useful to you.

Should there be any difficulty you encounter implementing something, please do not hesitate to contact me and I will gladly assist.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
DeadlyDonger
Posts: 19
Joined: Wed Jan 07, 2015 6:44 pm

Re: Change Registry Value at Uninstall

Hey Dan,

I was search ways to edit the registry using vbscript. I came across some examples and decided to create my own script the way I want with the values I want to set. This is what I came up with:

Code: Select all

Const HKEY_CLASSES_ROOT = &H80000000

strComputer = "."

Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

strKeyPath = "txtfile\shell\open\command"
strValueName = ""
strValue = "Test Value"

objRegistry.SetStringValue HKEY_CLASSES_ROOT, strKeyPath, strValueName, strValue
After saving as a .vbs script, I run it and nothing happens. Do you know what I did wrong? To test this I changed the value in the HKEY_CLASSES_ROOT\txtfile\shell\open\command\(Default) key and ran the script. Nothing happened
Dan wrote:Hello,

This can be done by using custom actions which backup and restore the registry entry. Please take a look on the Return orginal registry value if MSI is uninstalled forum thread which debates a similar subject.

You can also take a look on the Options to integrate and debug custom actions article which may be useful to you.

Should there be any difficulty you encounter implementing something, please do not hesitate to contact me and I will gladly assist.

Best regards,
Dan
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Change Registry Value at Uninstall

Hi,

Have you tried to use the script outside the installer or from the installler?
Before including the script to your installation package, please make sure that it works as expected outside.

You can also take a look on the How do I debug a .VBS custom action? article which may be useful to you.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
DeadlyDonger
Posts: 19
Joined: Wed Jan 07, 2015 6:44 pm

Re: Change Registry Value at Uninstall

I tried double clicking the scrip and it worked before. It worked when I was changing values in the HKEY_LOCAL_MACHINE with that exact code (Just replacing HKEY_CLASSES_ROOT with HKEY_LOCAL_MACHINE) but I have no idea why it isn't working.

Return to “Building Installers”