Determine msiexec exit code when msi file already installed

前端 未结 3 1642
清歌不尽
清歌不尽 2020-12-20 04:08

I launch msiexec in another process and wait for exit:

var p = new Process
{
    StartInfo =
    {
        FileName = \"msiexec\",
        Arguments = string         


        
3条回答
  •  没有蜡笔的小新
    2020-12-20 04:46

    MSI COM API: If you can use the MSI COM API you can use the ProductState property. In other words you can check for an installed product with two lines of code if you have the actual product code (How can I find the product GUID of an installed MSI setup?):

    Dim installer : Set installer = CreateObject("WindowsInstaller.Installer")
    MsgBox installer.ProductState("{00000000-0000-0000-0000-000000000001}") ' <= PRODUCT CODE
    

    Results: The normal states are 5 for installed or -1 for not installed:

    INSTALLSTATE_UNKNOWN   -1  The product is neither advertised or installed.
    INSTALLSTATE_ADVERTISED 1  The product is advertised but not installed.
    INSTALLSTATE_ABSENT     2  The product is installed for a different user.
    INSTALLSTATE_DEFAULT    5  The product is installed for the current user.
    

    Interactive VBScript: Here is a larger version of the VBScript with interactive input of product GUID in an InputBox - for use with any product GUID in an ad-hoc fashion: CheckProductState-Interactive.vbs


    Links:

    • Check for installed VCRedist
    • How can I find the product GUID of an installed MSI setup?
    • WiX Installer wrong about newer version already installed (find product details based on product code)

提交回复
热议问题