How to find the UpgradeCode and ProductCode of an installed application in Windows 7

后端 未结 11 1394
囚心锁ツ
囚心锁ツ 2020-11-27 04:36

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

11条回答
  •  暖寄归人
    2020-11-27 05:09

    Powershell handles tasks like this fairly handily:

    $productCode = (gwmi win32_product | `
                    ? { $_.Name -Like "*" } | `
                    % { $_.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"  }
    

提交回复
热议问题