I have an application installed on my machine. I also have its source code but somehow the ProductCode and UpgradeCode of this application were changed.
Now I want t
If you have msi installer open it with Orca (tool from Microsoft), table Property (rows UpgradeCode, ProductCode, Product version etc) or table Upgrade column Upgrade Code.
Try to find instller via registry: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall find required subkey and watch value InstallSource. Maybe along the way you'll be able to find the MSI file.
Powershell handles tasks like this fairly handily:
$productCode = (gwmi win32_product | `
? { $_.Name -Like "<PRODUCT NAME HERE>*" } | `
% { $_.IdentifyingNumber } | `
Select-Object -First 1)
You can then use it to get the uninstall information as well:
$wow = ""
$is32BitInstaller = $True # or $False
if($is32BitInstaller -and [System.Environment]::Is64BitOperatingSystem)
{
$wow = "\Wow6432Node"
}
$regPath = "HKEY_LOCAL_MACHINE\SOFTWARE$wow\Microsoft\Windows\CurrentVersion\Uninstall"
dir "HKLM:\SOFTWARE$wow\Microsoft\Windows\CurrentVersion\Uninstall" | `
? { $_.Name -Like "$regPath\$productCode" }
To everyone using:
Get-WMIObject win32_product
You should be aware that this will run a self-heal on every single MSI application installed on the PC. If you were to check eventvwr it will say it has finished reconfiguring each product.
In this case i use the following (a mixture of Yan Sklyarenko's method):
$Reg = @( "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*", "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" )
$InstalledApps = Get-ItemProperty $Reg -EA 0
$WantedApp = $InstalledApps | Where { $_.DisplayName -like "*<part of product>*" }
Now if you were to type:
$WantedApp.PSChildName
You would be given the following:
PS D:\SCCM> $WantedApp.PSChildName
{047904BA-C065-40D5-969A-C7D91CA93D62}
If your organization uses loads of MST's whilst installing applications you would want to avoid running self-heals encase they revert some crucial settings.
If you don't have the msi and you need the upgrade code, rather than the product code then the answer is here: How can I find the upgrade code for an installed application in C#?
You can use the MsiEnumProductsEx and MsiGetProductInfoEx methods to enumerate all the installed applications on your system and match the data to your application