如何在 Windows 7 中查找已安装应用程序的 UpgradeCode 和 ProductCode

发布于 2024-10-18 11:46:27 字数 196 浏览 1 评论 0原文

我的机器上安装了一个应用程序。我也有它的源代码,但不知何故该应用程序的 ProductCode 和 UpgradeCode 被更改了。

现在我想获取此已安装应用程序的 UpgradeCode 和 ProductCode。我觉得必须有一些工具可以做到这一点。

谁能告诉我如何获取已安装应用程序的 UpgradeCode 和 ProductCode?

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 to get the UpgradeCode and ProductCode of this installed application. I feel there must be some tool for this.

Can anyone kindly let me know how to get the UpgradeCode and ProductCode of an installed application?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

路弥 2024-10-25 11:46:28

如果有人想获取已安装的应用程序包代码,只需在命令提示符中使用您的应用程序名称执行以下命令即可。您将获得产品代码和包装代码。

wmic 产品,其中“Name like '%YOUR_APPLICATION_NAME%'”获取 IdentityingNumber、PackageCode

If anyone wants to get installed application package code, just execute below command with your application name in the command prompt. You will be getting product code along with package code.

wmic product where "Name like '%YOUR_APPLICATION_NAME%'" get IdentifyingNumber, PackageCode

2024-10-25 11:46:28

另一种过于复杂的解决方法,其优点是不必像以前的解决方法所要求的那样重新安装应用程序。这要求您有权访问 msi(或嵌入 msi 的 setup.exe)。

如果您有 Visual Studio 2012(或可能其他版本)并安装免费的“InstallShield LE”,则可以使用 InstallShield 创建新的安装项目。

“组织您的设置”步骤中的配置选项之一称为“升级路径”。打开升级路径的属性,在左侧窗格中右键单击“升级路径”并选择“新升级路径”...现在浏览到 msi(或包含 msi 的 setup.exe)并单击“打开”。升级代码将在您现在应该看到的右侧窗格的设置页面中填充。

Another way-too-complicated workaround, with the benefit of not having to re-install the application as the previous workaround required. This requires that you have access to the msi (or a setup.exe with the msi embedded).

If you have Visual Studio 2012 (or possibly other editions) and install the free "InstallShield LE", then you can create a new setup project using InstallShield.

One of the configuration options in the "Organize your Setup" step is called "Upgrade Paths". Open the properties for Upgrade Paths, and in the left pane right click "Upgrade Paths" and select "New Upgrade Path" ... now browse to the msi (or setup.exe containing the msi) and click "open". The upgrade code will be populated for you in the settings page in the right pane which you should now see.

梦萦几度 2024-10-25 11:46:28

在看到 Yan Sklyarenko解决方法(当前)。但是,如果您/其他人能找到一种方法(至少)从 MSI 中查找 UpgradeCode 和 ProductCode,请继续阅读。

来自 http://www.dwarfsoft.com/ blog/2010/06/22/msi-package-code-fun/,修改为允许(使用 wscript.exe 启动时)每个 MSI 弹出一个信息框(在 1023 处截断)字符,由于 wscript.echo 限制);能够从 GUI 和 CLI 输入 MSI;一些基本的人类输入验证;删除了调试代码('Set oDatabase)和 1 个错误修复(DB.OpenView)。

'Created by:   Chris Bennett
'Created Date: 22/06/2010
'Description:
'   Opens up MSI file(s) Passed as Arguments & returns ProductName, ProductCode,
'   The HKCR key created from ProductCode (a Packed GUID of ProductCode), the 
'   PackageCode and the UpgradeCode of the MSI. Much quicker than getting these
'   out of the MSI's the Manual Way.

参考文献:
http://msdn.microsoft.com/en-我们/库/aa369794%28VS.85%29.aspx
http://www.eggheadcafe.com/forumarchives/platformsdkmsi/Jan2006/post25948124。 asp

if wscript.arguments.count = 0 then
  MSIs = inputbox("Enter in * delimited list of MSI's to query (Max 254 characters)", "MSI Product Details")
  MSIs = split(MSIs,"*")
else
  set MSIs = wscript.arguments
end if

set objFS = createobject("scripting.filesystemobject")
For Each MSIPath in MSIs
  if objFS.fileexists(MSIPath) then
    Set MSIDetails = EvaluateMSI(MSIPath)
    MSIDetails = MSIPath & ": " & vbcrlf & vbcrlf & "Product Name: " &_
    MSIDetails("ProductName") & vbcrlf & "Product Code: " &_
    MSIDetails("ProductCode") & vbcrlf & "Product Key : " &_
    "HKCR\Installer\Products\" & PackGUID(MSIDetails("ProductCode")) &_
    vbcrlf & "Package Code: " & MSIDetails("PackageCode") & vbcrlf &_
    "Upgrade Code: " & MSIDetails("UpgradeCode") & vbcrlf
    WScript.Echo MSIDetails
  else
    wscript.echo "Inaccessible; Non-existant; or Error in Path for:" & vbcrlf & MSIPath & vbcrlf & "... skipping"
  end if
Next

Function EvaluateMSI(MSIPath)
  On Error Resume Next
  ' create installer object
  Set oInstaller = CreateObject("WindowsInstaller.Installer")
  ' open msi in read-only mode
  Set oDatabase = oInstaller.OpenDatabase(MSIPath, 0)
  Set objDictionary = CreateObject("Scripting.Dictionary")
  ' Get Package Code from Summary Information Stream   
  Set streamobj = oDatabase.SummaryInformation(0) '0 = read only
  objDictionary("PackageCode") = streamobj.Property(9)
  ' Get Product Name from MSI Database
  Set View = oDatabase.OpenView("Select `Value` From Property WHERE `Property`='ProductName'")
  View.Execute
  Set ProductName = View.Fetch
  objDictionary("ProductName") = ProductName.StringData(1)

  ' Get Product Code from MSI Database
  Set View = oDatabase.OpenView("Select `Value` From Property WHERE `Property`='ProductCode'")
  View.Execute
  Set ProductCode = View.Fetch
  objDictionary("ProductCode") = ProductCode.StringData(1)

  ' Get Upgrade Code from MSI Database
  Set View = oDatabase.OpenView("Select `Value` From Property WHERE `Property`='UpgradeCode'")
  View.Execute
  Set UpgradeCode = View.Fetch
  objDictionary("UpgradeCode") = UpgradeCode.StringData(1)

  Set EvaluateMSI = objDictionary
  On Error Goto 0
End Function

Function PackGUID(guid)  
  PackGUID = ""  
  '*  
  Dim temp  
  temp = Mid(guid,2,Len(guid)-2)  
  Dim part  
  part = Split(temp,"-")  
  Dim pack  
  pack = ""  
  Dim i, j  
  For i = LBound(part) To UBound(part)
    Select Case i
      Case LBound(part), LBound(part)+1, LBound(part)+2
        For j = Len(part(i)) To 1 Step -1  
          pack = pack & Mid(part(i),j,1)  
        Next  
      Case Else
        For j = 1 To Len(part(i)) Step 2  
          pack = pack & Mid(part(i),j+1,1) & Mid(part(i),j,1)  
      Next  
    End Select
  Next  
  '*  
  PackGUID = pack  
End Function

如果需要在弹出窗口中复制并粘贴任何 GUID,我倾向于发现使用后续输入框最简单,例如 inputbox "","",MSIDetails

Hadn't found any way of finding out the UpgradeCode from an installed application, before seeing Yan Sklyarenko's workaround (currently) above. But if you/anyone else would find a way of finding out (at least) both UpgradeCode and ProductCode from a MSI, read on.

From http://www.dwarfsoft.com/blog/2010/06/22/msi-package-code-fun/, modified to allow (when launched with wscript.exe) one popup box of info per MSI (Trunicated at 1023 chars, due to wscript.echo limitation); able to input MSI(s) from the GUI as well as the CLI; some basic human input validation; removed debug code (' Set oDatabase) and 1 bug fix (DB.OpenView).

'Created by:   Chris Bennett
'Created Date: 22/06/2010
'Description:
'   Opens up MSI file(s) Passed as Arguments & returns ProductName, ProductCode,
'   The HKCR key created from ProductCode (a Packed GUID of ProductCode), the 
'   PackageCode and the UpgradeCode of the MSI. Much quicker than getting these
'   out of the MSI's the Manual Way.

References:
http://msdn.microsoft.com/en-us/library/aa369794%28VS.85%29.aspx
http://www.eggheadcafe.com/forumarchives/platformsdkmsi/Jan2006/post25948124.asp

if wscript.arguments.count = 0 then
  MSIs = inputbox("Enter in * delimited list of MSI's to query (Max 254 characters)", "MSI Product Details")
  MSIs = split(MSIs,"*")
else
  set MSIs = wscript.arguments
end if

set objFS = createobject("scripting.filesystemobject")
For Each MSIPath in MSIs
  if objFS.fileexists(MSIPath) then
    Set MSIDetails = EvaluateMSI(MSIPath)
    MSIDetails = MSIPath & ": " & vbcrlf & vbcrlf & "Product Name: " &_
    MSIDetails("ProductName") & vbcrlf & "Product Code: " &_
    MSIDetails("ProductCode") & vbcrlf & "Product Key : " &_
    "HKCR\Installer\Products\" & PackGUID(MSIDetails("ProductCode")) &_
    vbcrlf & "Package Code: " & MSIDetails("PackageCode") & vbcrlf &_
    "Upgrade Code: " & MSIDetails("UpgradeCode") & vbcrlf
    WScript.Echo MSIDetails
  else
    wscript.echo "Inaccessible; Non-existant; or Error in Path for:" & vbcrlf & MSIPath & vbcrlf & "... skipping"
  end if
Next

Function EvaluateMSI(MSIPath)
  On Error Resume Next
  ' create installer object
  Set oInstaller = CreateObject("WindowsInstaller.Installer")
  ' open msi in read-only mode
  Set oDatabase = oInstaller.OpenDatabase(MSIPath, 0)
  Set objDictionary = CreateObject("Scripting.Dictionary")
  ' Get Package Code from Summary Information Stream   
  Set streamobj = oDatabase.SummaryInformation(0) '0 = read only
  objDictionary("PackageCode") = streamobj.Property(9)
  ' Get Product Name from MSI Database
  Set View = oDatabase.OpenView("Select `Value` From Property WHERE `Property`='ProductName'")
  View.Execute
  Set ProductName = View.Fetch
  objDictionary("ProductName") = ProductName.StringData(1)

  ' Get Product Code from MSI Database
  Set View = oDatabase.OpenView("Select `Value` From Property WHERE `Property`='ProductCode'")
  View.Execute
  Set ProductCode = View.Fetch
  objDictionary("ProductCode") = ProductCode.StringData(1)

  ' Get Upgrade Code from MSI Database
  Set View = oDatabase.OpenView("Select `Value` From Property WHERE `Property`='UpgradeCode'")
  View.Execute
  Set UpgradeCode = View.Fetch
  objDictionary("UpgradeCode") = UpgradeCode.StringData(1)

  Set EvaluateMSI = objDictionary
  On Error Goto 0
End Function

Function PackGUID(guid)  
  PackGUID = ""  
  '*  
  Dim temp  
  temp = Mid(guid,2,Len(guid)-2)  
  Dim part  
  part = Split(temp,"-")  
  Dim pack  
  pack = ""  
  Dim i, j  
  For i = LBound(part) To UBound(part)
    Select Case i
      Case LBound(part), LBound(part)+1, LBound(part)+2
        For j = Len(part(i)) To 1 Step -1  
          pack = pack & Mid(part(i),j,1)  
        Next  
      Case Else
        For j = 1 To Len(part(i)) Step 2  
          pack = pack & Mid(part(i),j+1,1) & Mid(part(i),j,1)  
      Next  
    End Select
  Next  
  '*  
  PackGUID = pack  
End Function

If one needs to copy&paste any of the GUID's in the popup, I tend to find it easiest to use a subsequent inputbox, like inputbox "","",MSIDetails

沉溺在你眼里的海 2024-10-25 11:46:28

如果您没有 msi 并且需要升级代码,而不是产品代码,那么答案就在这里:如何在 C# 中找到已安装应用程序的升级代码?

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#?

信愁 2024-10-25 11:46:27

重要自从这个答案最初发布以来已经有一段时间了,聪明的人想出了更明智的答案。检查我该如何找到已安装的 MSI 文件的升级代码? 如果您需要可靠且全面的方法,请来自 @ Stein Åsmul。


这是另一种方法(您不需要任何工具):

  • 打开系统注册表并搜索HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall 键(如果是 64 位计算机上的 32 位安装程序,则可能位于 HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows \CurrentVersion\Uninstall 代替)。
  • 该键下列出的 GUID 是该计算机上安装的产品,
  • 找到您正在谈论的产品 - 只需一步一步,直到您在右侧窗格中看到其名称为止。

您停止的 GUID 是 ProductCode。

现在,如果您确定重新安装此应用程序会顺利进行,您可以运行以下命令行:

msiexec /i {产品代码 GUID-此处}
重新安装=全部重新安装模式=omus /l*v
日志.txt

这将“修复”您的应用程序。现在查看日志文件并搜索“UpgradeCode”。该值被转储到那里。

注意:只有当您确定重新安装流程正确实施并且这不会破坏您已安装的应用程序时,您才应该执行此操作。


IMPORTANT: It's been a while since this answer was originally posted, and smart people came up with wiser answers. Check How can I find the Upgrade Code for an installed MSI file? from @ Stein Åsmul if you need a solid and comprehensive approach.


Here's another way (you don't need any tools):

  • open system registry and search for HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall key (if it's a 32-bit installer on a 64-bit machine, it might be under HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall instead).
  • the GUIDs listed under that key are the products installed on this machine
  • find the one you're talking about - just step one by one until you see its name on the right pane

This GUID you stopped on is the ProductCode.

Now, if you're sure that reinstallation of this application will go fine, you can run the following command line:

msiexec /i {PRODUCT-CODE-GUID-HERE}
REINSTALL=ALL REINSTALLMODE=omus /l*v
log.txt

This will "repair" your application. Now look at the log file and search for "UpgradeCode". This value is dumped there.

NOTE: you should only do this if you are sure that reinstall flow is implemented correctly and this won't break your installed application.

北方。的韩爷 2024-10-25 11:46:27

返回结果需要一些时间,很容易需要几十秒,但是 wmic 效果很好,可以编写脚本:

wmic product where "Name like '%Word%'" get Name,Version,IdentifyingNumber

结果:

IdentifyingNumber                       Name                                      Version
{90140000-001B-0409-0000-0000000FF1CE}  Microsoft Office Word MUI (English) 2010  14.0.6029.1000

IdentifingNumber 是 ProductCode。 我没有看到 UpgradeCode 的属性,但也许它可能隐藏在其他内容下。请参阅 http://quux.wiki.zoho.com/WMIC-Snippets.html 对于许多其他示例,包括卸载

wmic path win32_product where "name = 'HP Software Update'" call Uninstall

有关 UpgradeCode,请参阅 如何找到已安装 MSI 文件的升级代码?

It takes some time to return results, easily many tens of seconds, but wmic works well and can be scripted:

wmic product where "Name like '%Word%'" get Name,Version,IdentifyingNumber

result:

IdentifyingNumber                       Name                                      Version
{90140000-001B-0409-0000-0000000FF1CE}  Microsoft Office Word MUI (English) 2010  14.0.6029.1000

The IdentifingNumber is the ProductCode. I didn't see a property for UpgradeCode, but perhaps it might be buried under something else. See http://quux.wiki.zoho.com/WMIC-Snippets.html for many other examples, including uninstall:

wmic path win32_product where "name = 'HP Software Update'" call Uninstall

For UpgradeCode see the excellent and detailed answer to How can I find the Upgrade Code for an installed MSI file?

鱼窥荷 2024-10-25 11:46:27

对于所有使用者:

Get-WMIObject win32_product

您应该知道,这将在 PC 上安装的每个 MSI 应用程序上运行自我修复。如果您要检查 eventvwr,它会说它已完成每个产品的重新配置。

在这种情况下,我使用以下方法(Yan Sklyarenko 方法的混合):

$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>*" }

现在,如果您输入:

$WantedApp.PSChildName

您将得到以下信息:

PS D:\SCCM> $WantedApp.PSChildName
{047904BA-C065-40D5-969A-C7D91CA93D62}

如果您的组织在安装应用程序时使用 MST 负载,您将希望避免运行自我修复包他们恢复一些关键设置。

  • 注意 - 这将找到您的产品代码,然后可以按照 Yan 提到的那样找到升级。不过,我通常只使用“InstEd It!”或“Orca”,然后转到 MSI 的属性表,它会在顶部列出它们。

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.

  • Note - This will find your product code, then the upgrade can be found as Yan mentioned. I usually, though, just use either 'InstEd It!' or 'Orca' then go to the Property table of the MSI and it lists them right at the top.
慕烟庭风 2024-10-25 11:46:27

如果您有 msi 安装程序,请使用 Orca(Microsoft 的工具)打开它,表属性(行升级代码、产品代码、产品版本等)或表升级列升级代码。

尝试通过注册表查找安装程序:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall 找到所需的子项并观察值InstallSource。也许在此过程中您将能够找到 MSI 文件。

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.

撩动你心 2024-10-25 11:46:27

Powershell 相当方便地处理这样的任务:

$productCode = (gwmi win32_product | `
                ? { $_.Name -Like "<PRODUCT NAME HERE>*" } | `
                % { $_.IdentifyingNumber } | `
                Select-Object -First 1)

然后您也可以使用它来获取卸载信息:

$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"  }

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"  }
江心雾 2024-10-25 11:46:27

您可以使用 MsiEnumProductsExMsiGetProductInfoEx 方法枚举系统上所有已安装的应用程序并将数据与您的应用程序相匹配

You can use the MsiEnumProductsEx and MsiGetProductInfoEx methods to enumerate all the installed applications on your system and match the data to your application

污味仙女 2024-10-25 11:46:27

在使用 PowerShell 5 的 Windows 10 预览版中,我可以看到您可以执行以下操作:

$info = Get-Package -Name YourInstalledProduct
$info.Metadata["ProductCode"]

不熟悉甚至不确定是否所有产品都有 UpgradeCode,但是 根据这篇文章 您需要从此注册表路径搜索 UpgradeCode:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UpgradeCodes

不幸的是,注册表项值是 ProductCode,注册表项是 UpgradeCode。

In Windows 10 preview build with PowerShell 5, I can see that you can do:

$info = Get-Package -Name YourInstalledProduct
$info.Metadata["ProductCode"]

Not familiar with even not sure if all products has UpgradeCode, but according to this post you need to search UpgradeCode from this registry path:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UpgradeCodes

Unfortunately, the registry key values are the ProductCode and the registry keys are the UpgradeCode.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文