How can get UninstallString?

Hello,

I can’t get the value of UninstallString or QuietUninstallString for a Key…
I used Get-RegistryKey function.

How can I do this ?

Cordially

Are you trying to get the UninstallString and then have it uninstall software based on that reg key?

Are you doing something like this? This works for me when 7-Zip 21.07 x64 is installed

        Get-RegistryKey -Key "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{23170F69-40C1-2702-2107-000001000000}" -Value "UninstallString"

If you are trying to uninstall an MSI based on its UninstallString in the registry this works for me but I personally wouldn’t do it this way. However you may be trying to do something special I haven’t considered. Maybe this will work for you. This will work for MSI’s but not EXEs. You may have to modify it for EXEs.

        Show-InstallationProgress -StatusMessage "Get-Uninstall String" -WindowLocation 'TopCenter'
        start-sleep -s 2
        $UninstallKey = Get-RegistryKey -Key "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{23170F69-40C1-2702-2107-000001000000}" -Value "UninstallString"
        Start-Sleep -S 2
        Show-InstallationProgress -StatusMessage "$UninstallKey" -WindowLocation 'TopCenter'
        Start-Sleep -s 2
        Show-InstallationProgress -StatusMessage "Trim Key and Uninstall" -WindowLocation 'TopCenter'
        $UninstallKey = $UninstallKey -replace "MsiExec.exe /I"
        Execute-MSI -Action Uninstall -Path $UninstallKey -Parameters '/qb!'

Best of Luck.

1 Like

use PSADT’s Get-InstalledApplication function.

Thank you very much ! But I have an error with the first line :confused:
What is the type of $UninstallKey variable ? I don’t know if the problem is at this point but since yesterday I have the same problem…

“[Uninstallation] [Get-RegistryKey] [Info] :: Get registry key [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\pgAdmin 4v2_is1] value [UninstallString]”
“[Uninstallation] [Deploy Application] [Error] :: Error Record:”

it’s not an msi but a .exe. I will use after that to uninstall :
“Execute-Process $UninstallKey -Parameters “/VERYSILENT /NORESTART” -PassThru”

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.