Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

msiexec quiet installation when the package is already installed

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.

like image 693
user88637 Avatar asked Jun 03 '09 15:06

user88637


People also ask

How do I install MSI silently?

You should be able to use the /quiet or /qn options with msiexec to perform a silent install. MSI packages export public properties, which you can set with the PROPERTY=value syntax on the end of the msiexec parameters. You can read the options for msiexec by just running it with no options from Start -> Run.

How do I install MSP files silently?

msp. Open a command prompt and run the silent installer by specifying the /p parameter to the Msiexec command. To generate a log file, specify the /l option.


2 Answers

Is it your package? If so, put in a prerequisite condition that checks if some key file or registry entry doesn't exist yet.

If it's not your package, wrap it in something (another installer or an exe) that will make the check.

like image 25
DaveE Avatar answered Nov 15 '22 09:11

DaveE


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
like image 125
saschabeaumont Avatar answered Nov 15 '22 07:11

saschabeaumont