Msiexec quiet installation when the package is already installed

installationwindows-installer

I have the following problematic scenario:

Problematic Scenrio Description Begin—————————

I use msiexec to install a package in quiet mode in the following way:

msiexec /i c:\mypackage.msi /quiet

Now I have the package installed. Let's say I entered the command above again:

msiexec /i c:\mypackage.msi /quiet

Problematic Scenrio Description End—————————

Now since the package is already installed, the installation should fail. But I have no indication for that.

I use the log option in order to get a log going:

msiexec /i c:\mypackage.msi /quiet /l* log.txt

When errors occur I do see them in the log but in the scenario depicted above the log is empty. There is also nothing written to the system event log. So my question is, How can I get an indication that the installation (The second one) didn't go?

Notes:

I am not willing to solve this problem by writing a batch script that will check if the package is installed prior to the call to msiexec. The reason is that it contradicts our customer deployment requirements.

I have a DLL custom action data, in the second time, the DLL is not activated so I can't use the DLL in order to write the failure somewhere.

Best Answer

Installation does not fail if the package is already installed, it was "successfully reconfigured"

In order to check if a Windows Installer package is installed on the system or not, you're best to use the Windows SDK (not a batch file) - here's a sample script that iterates the list of installed products and triggers MSIEXEC if it is not already installed. (This example searches by name, alternatively you could search by package code)

Option Explicit

Dim productName:productName = "My Awesome Product"

Dim installer : Set installer = Nothing
Set installer = Wscript.CreateObject("WindowsInstaller.Installer")

Dim productCode, property, value, message

For Each productCode In installer.Products
    If InStr(1, LCase(installer.ProductInfo(productCode, "ProductName")), LCase(productName)) Then Exit For
Next

If IsEmpty(productCode) Then 
    Dim WshShell, oExec
    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Exec("msiexec /i mypackage.msi /qb")
Else
    Wscript.Echo productName & " is already installed."
    Wscript.Quit 2
End If
Related Topic