因此,WindowsInstaller會爲安裝的軟件包提供任何ID,例如:673538CFB3FFAAC4380E12843BBFC789或BA342DECAB7C24D3699041FEA5F66C10等。如何通過已知安裝包找到此ID?Windows安裝程序ID的
1
A
回答
0
下面是一個示例VBScript,它從任何給定的MSI文件中提取各種有用的屬性,而無需安裝它。您可以使用工具手動打開給定的包,如Orca
或者,如果你正在尋找識別當前已安裝的軟件包,可以使用Windows Installer API重複安裝的項目,或者在命令行中使用msiinv.exe
Option Explicit
Dim argCount:argCount = Wscript.Arguments.Count
Dim sPackageCode, sProductCode, sProductVersion, sDownloadURL, sConfig, sProductName
If (argCount = 0) Then
WScript.Echo "Usage: msiinfo.vbs <filename>"
WScript.Quit 1
End If
Dim MSI_FILE : MSI_FILE = Wscript.Arguments(0)
Dim filesys : Set filesys=CreateObject("Scripting.FileSystemObject")
If Not filesys.FileExists(MSI_FILE) Then
WScript.Echo "Unable to find " & MSI_FILE & ", exiting"
WScript.Quit 1
End If
Dim installer, database, view, result
Set installer = CreateObject("WindowsInstaller.Installer")
Set database = installer.OpenDatabase (MSI_FILE, 0)
Dim sumInfo : Set sumInfo = installer.SummaryInformation(MSI_FILE, 0)
sPackageCode = sumInfo.Property(9) ' PID_REVNUMBER = 9, contains the package code.
Dim sDetails : sDetails = "ProductVersion: " & getproperty("ProductVersion") & vbCrLf _
& "ProductCode: " & getproperty("ProductCode") & vbCrLf _
& "PackageCode: " & sPackageCode & vbCrLf _
& "ProductName: " & getproperty("ProductName")
WScript.Echo sDetails
Function getproperty(property)
Set view = database.OpenView ("SELECT Value FROM Property WHERE Property='" & property & "'")
view.Execute
Set result = view.Fetch
getproperty = result.StringData(1)
End Function
0
如果你喜歡使用PowerShell:
$winInstaller = New-Object -ComObject WindowsInstaller.Installer
$msiInstalledApps = @()
foreach($item in $winInstaller.GetType().InvokeMember("Products","GetProperty",$null, $winInstaller, $null)){
$msiInstalledApps += New-Object PSObject -Property ($hash = [ordered]@{
Language = $winInstaller.GetType().InvokeMember("ProductInfo","GetProperty",$null, $winInstaller, @($item, "Language"))
ProductName = $winInstaller.GetType().InvokeMember("ProductInfo","GetProperty",$null, $winInstaller, @($item, "ProductName"))
PackageCode = $winInstaller.GetType().InvokeMember("ProductInfo","GetProperty",$null, $winInstaller, @($item, "PackageCode"))
Transforms = $winInstaller.GetType().InvokeMember("ProductInfo","GetProperty",$null, $winInstaller, @($item, "Transforms"))
AssignmentType = $winInstaller.GetType().InvokeMember("ProductInfo","GetProperty",$null, $winInstaller, @($item, "AssignmentType"))
PackageName = $winInstaller.GetType().InvokeMember("ProductInfo","GetProperty",$null, $winInstaller, @($item, "PackageName"))
InstalledProductName = $winInstaller.GetType().InvokeMember("ProductInfo","GetProperty",$null, $winInstaller, @($item, "InstalledProductName"))
VersionString = $winInstaller.GetType().InvokeMember("ProductInfo","GetProperty",$null, $winInstaller, @($item, "VersionString"))
RegCompany = $winInstaller.GetType().InvokeMember("ProductInfo","GetProperty",$null, $winInstaller, @($item, "RegCompany"))
RegOwner = $winInstaller.GetType().InvokeMember("ProductInfo","GetProperty",$null, $winInstaller, @($item, "RegOwner"))
ProductID = $winInstaller.GetType().InvokeMember("ProductInfo","GetProperty",$null, $winInstaller, @($item, "ProductID"))
ProductIcon = $winInstaller.GetType().InvokeMember("ProductInfo","GetProperty",$null, $winInstaller, @($item, "ProductIcon"))
InstallLocation = $winInstaller.GetType().InvokeMember("ProductInfo","GetProperty",$null, $winInstaller, @($item, "InstallLocation"))
InstallSource = $winInstaller.GetType().InvokeMember("ProductInfo","GetProperty",$null, $winInstaller, @($item, "InstallSource"))
InstallDate = $winInstaller.GetType().InvokeMember("ProductInfo","GetProperty",$null, $winInstaller, @($item, "InstallDate"))
Publisher = $winInstaller.GetType().InvokeMember("ProductInfo","GetProperty",$null, $winInstaller, @($item, "Publisher"))
LocalPackage = $winInstaller.GetType().InvokeMember("ProductInfo","GetProperty",$null, $winInstaller, @($item, "LocalPackage"))
HelpLink = $winInstaller.GetType().InvokeMember("ProductInfo","GetProperty",$null, $winInstaller, @($item, "HelpLink"))
HelpTelephone = $winInstaller.GetType().InvokeMember("ProductInfo","GetProperty",$null, $winInstaller, @($item, "HelpTelephone"))
URLInfoAbout = $winInstaller.GetType().InvokeMember("ProductInfo","GetProperty",$null, $winInstaller, @($item, "URLInfoAbout"))
URLUpdateInfo = $winInstaller.GetType().InvokeMember("ProductInfo","GetProperty",$null, $winInstaller, @($item, "URLUpdateInfo"))
})
}
$msiInstalledApps
相關問題
- 1. Windows安裝程序安裝
- 2. Windows安裝程序
- 3. 的Windows安裝程序
- 4. Windows的安裝程序
- 5. Windows安裝程序安裝舊文件
- 6. 使用msi安裝程序的安裝程序windows服務
- 7. Windows安裝程序的Windows Server 2008 R2
- 8. 創建Windows安裝程序
- 9. Windows安裝程序msi包
- 10. Windows安裝程序XML(WiX)
- 11. Windows安裝程序問題
- 12. 模擬Windows安裝程序
- 13. Windows安裝程序和setup.exe
- 14. Windows安裝程序3.1
- 15. Windows安裝程序包
- 16. 如何安裝Windows程序?
- 17. Windows服務安裝程序
- 18. 未安裝應用程序安裝程序ID
- 19. inno安裝程序繞過Windows安裝程序?
- 20. BTSTask安裝程序 - Windows安裝程序錯誤1001
- 21. 使用Windows安裝程序向GAC安裝程序集
- 22. 維克斯/ Windows安裝程序:安裝順序文檔
- 23. XML中的Windows安裝程序
- 24. 安裝Android的Windows驅動程序8
- 25. 在windows中安裝firefox exetension的程序?
- 26. 在Windows 7上的python安裝程序
- 27. Windows 7上的RubyMine 3.0安裝程序
- 28. COM組件的Windows安裝程序
- 29. Install4j創建的Windows安裝程序
- 30. 免費的Windows安裝程序
這個問題似乎是類似http://stackoverflow.com/questions/2467429/c-check-installed-programms – Ciprian