开发者

Windows installer ID's

开发者 https://www.devze.com 2023-04-12 05:15 出处:网络
So, WindowsInstaller开发者_JAVA技巧 takes any ID\'s for installed packages, example: 673538CFB3FFAAC4380E12843BBFC789 or BA342DECAB7C24D3699041FEA5F66C10 etc. How I can find this ID by known installin

So, WindowsInstaller开发者_JAVA技巧 takes any ID's for installed packages, example: 673538CFB3FFAAC4380E12843BBFC789 or BA342DECAB7C24D3699041FEA5F66C10 etc. How I can find this ID by known installing package?


Here's a sample VBScript that pulls various useful properties from any given MSI file without needing to install it. You can manually open a given package using a tool such as Orca

Alternatively if you are looking to identify currently installed packages, you can iterate installed items using the Windows Installer API, or from the command line using 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 


If you like to use 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
0

精彩评论

暂无评论...
验证码 换一张
取 消