TTbeelivio
Posts: 9
Joined: Fri Mar 13, 2020 1:39 pm

Modify registry key UninstallString

Hello people,

I have a request to modify the registry key HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\UninstallString

-from- MsiExec.exe /I {auto-generated-bla-bla}
-to- MsiExec.exe /X {auto-generated-bla-bla}

during the install process.

I am struggling to find a way to modify it without writing a powershell script.

Is this possible ?
Catalin
Posts: 7606
Joined: Wed Jun 13, 2018 7:49 am

Re: Modify registry key UninstallString

Hello and welcome to Advanced Installer forums,

Yes, that should be possible.

Have you tried using our "Registry" page?

For instance, you can recreate the registry hierarchy in the "Registry"page:

Code: Select all

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\UninstallString
and have the package create what registry you need. Also, if the registry entry already exists (which is your case), you can choose to replace its value with the string give in your installation package.

One thing to be kept in mind here is the registry redirection. If your package is a 32-bit package and it is installed on a 64-bit machine, the it will be redirected in the WOW6432Node hive.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
TTbeelivio
Posts: 9
Joined: Fri Mar 13, 2020 1:39 pm

Re: Modify registry key UninstallString

Hi Catalin,
thank you for your valuable note regarding redirection of x64 and x86.

I have tried to recreate the reg key tree structure in the Registry as you instructed however without success after trying the installation MSI package.

Image (Do not know why is this broken - link exists)
LinkToImage: https://prnt.sc/rfu5jl

LinkToImage value properties: https://prnt.sc/rfuckc

Could you recommend some other approach or am i missing something ?

Also -
I am aware by accident that there is an upgrade code {bla-bla} besides product code {bla-bla}.

If i should be cautious about this as well and not hard code the productcode, is there a way to detect this CODE automatically without hardcoding it when manually recreating the registry key tree structure?

Best regards
Catalin
Posts: 7606
Joined: Wed Jun 13, 2018 7:49 am

Re: Modify registry key UninstallString

Hello Timotej,

This might be happening due to the fact that you manually created the "Wow6432Node" registry entry.

Normally, the redirection is done manually, therefore you do not need to specify it (e.g. if your setup is of 32-bit type and the machine is of 64-bit type, then the registry values will automatically be redirect in the Wow6432Node)

In your e-mail, you have mentioned something about a ProductCode. Could you pelase give me some more details about which ProductCode you are refering to? Do you want to automatically detect the ProductCode used in an earlier version of your installer? For instance, let's consider you have version 1.0 installed (which has a ProductCode). Upon installing version 1.1, you want to get the ProductCode of version 1.0 in it? If so, this can be done through the OLDPRODUCTS property.

In what regards the system platform (either 64 or 32-bit), this can be done through the VersionNT64 property. If this property is set, then it means the Windows is of 64-bit type and if it's not set, it means the system is of 32-bit type. We can use this property as it follows:

VersionNT64 --> Windows x64

NOT VersionNT64 --> WIndows x32

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
TTbeelivio
Posts: 9
Joined: Fri Mar 13, 2020 1:39 pm

Re: Modify registry key UninstallString

The issue is that i need to change the

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{this-is-the-product-code} /UninstallString registry value from /I to /X

as the final step of the installation.

The steps that you mentioned regarding recreating the registry hierarchy in the "Registry" page is not possible IMHO since the product code is dynamic property.

Even if i hard code the product key in registry hierarchy = it is not overwriting the value when installation has finished.

Is there a way for me to achieve this ?
Catalin
Posts: 7606
Joined: Wed Jun 13, 2018 7:49 am

Re: Modify registry key UninstallString

Hello TImotej,

I have tested this right now and everything worked as expected on my end.

Here is the test registry entry that I have created:
registry.png
registry.png (81.33 KiB) Viewed 9774 times
Here is how I recreated the registry entry in Advanced Installer:
regAI.png
regAI.png (83.89 KiB) Viewed 9774 times

After installing the setup, I have checked and noticed that the registry entry was correctly changed.
The steps that you mentioned regarding recreating the registry hierarchy in the "Registry" page is not possible IMHO since the product code is dynamic property.
In what regards this, could you please give me some more details about the ProductCode? How is it related to your setup? Depending on how the ProductCode is related to your package, we may find a way to dynamically retrieve its value.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
TTbeelivio
Posts: 9
Joined: Fri Mar 13, 2020 1:39 pm

Re: Modify registry key UninstallString

Catalin,
Thanks for your fast response - i confirm that when you do it this way it is alright however,

By default when i install the application in windows 10 the installer places the reg key(PRODUCT CODE) on this location
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{this-is-the-product-code-that-i-can-not-access-dynamically-as-property}. ( even if i access it statically as you did in the example above - the value is not changed into /X )

I have this powershell inline script that changes the UninstallString registry value successfully when i run it in powershell cmd window, however
when i include it in the installer as the final step(CUSTOM ACTION - finish execution dialog stage)- the registry value is not overwritten.

Parameters: (i retreive the pcode with success)

Code: Select all

-pcode "[ProductCode]"

Code: Select all

Param($pcode)
$w=$pcode
#$propValue = AI_GetMsiProperty ProductCode

if ((Get-WmiObject Win32_OperatingSystem).OSArchitecture -eq "64-bit")
{
	set-location -path HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\
	Set-ItemProperty -Path "$w" -Name "UninstallString" -Value "MsiExec.exe /X$w"
}
else
{
	set-location -path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\
	Set-ItemProperty -Path "$w" -Name "UninstallString" -Value "MsiExec.exe /X$w"
}

I hope we clarified the issue now.
Catalin
Posts: 7606
Joined: Wed Jun 13, 2018 7:49 am

Re: Modify registry key UninstallString

Hello TImotej,
Thanks for your fast response - i confirm that when you do it this way it is alright however
You are always welcome!

In what regards the PowerShell script, this most probably happens because the script does not have the required privileges in order to change the registry value.

In order to fix this, either run the MSI (open an elevated command line and launch the msi from there)/EXE (right click --> "Run as administrator") elevated from the start manually or go to "Install Parameters" page and check the "Run as administrator" option.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
TTbeelivio
Posts: 9
Joined: Fri Mar 13, 2020 1:39 pm

Re: Modify registry key UninstallString

Hello again,
In what regards the PowerShell script, this most probably happens because the script does not have the required privileges in order to change the registry value.
Awesome, that did the trick.

Just wondering, is there another (best practice) approach i could use to achieve the same ?

:mrgreen:
Catalin
Posts: 7606
Joined: Wed Jun 13, 2018 7:49 am

Re: Modify registry key UninstallString

Hello TImotej,
Awesome, that did the trick.
I am glad you got this working :)
Just wondering, is there another (best practice) approach i could use to achieve the same ?
I am afraid that I am not aware of any other way in which you can achieve that than the one I've already presented above.

Few things I would like to mention here:

1. In order to automate the ProductCode retrieval in "Registry" page, all you need to do is to create a new key, like this:

Code: Select all

[ProductCode]
2. I just realised that you want to overwrite a registry that is automatically written by the setup package. Most probably, this does not work because one writing operation happens before the other (e.g. the one that should overwrite with the correct value takes places before the other one). With that being said, I am afraid that what we've discussed in the previous threads no longer apply. A custom approach may indeed be needed here (e.g. your custom action).

Please accept my apologies for misunderstanding your scenario. I thought you want to overwrite a registry key that already exists (before installing) on the machine, in which case the scenario presented above by me would work.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”