Prasad Honrao
Prasad Honrao

Reputation: 211

Automate deployment of Excel AddIn

I have created an Excel Add-in using AddIn Express .Net component. Business users install the add-in using the MSI provided by the build team. Everytime we make any changes to the product and provide it to business users, they need to manually uninstall existing Add-in and then install new one with the updated MSI.

I wanted to know if there is any way this process can be automated using some windows batch file, scriptcs or a small C# console program. Ideally, it should uninstall existing Add-in, wait for uninstallion process to complete and then install new AddIn.

I tried multiple options using Msiexec, scriptcs etc, but without any success so far. My main problem is once the existing add-in uninstallion process starts, it immediately starts installing new Addin, which then pops up standard windows message that 'Installation is already in progress...'

Any help would be appreciated.

Thanks

Upvotes: 1

Views: 1747

Answers (2)

Stein Åsmul
Stein Åsmul

Reputation: 42126

A few things here:

  1. First question is if you are aware of the xlstart folder in Excel which allows you to easily load certain addin files on Excel startup just by putting them into this folder. As far as I know you can't disable addins this way via the Excel GUI, you have to remove them from the xlstart folder to not load them into Excel.

  2. Second issue is that you should update your MSI file to use a major upgrade so that it automatically removes the existing MSI whilst installing the new one. This would probably remove the whole problem that you describe.

  3. Finally you should be able to use start wait msiexec.exe /i /qn File.msi to have your batch file wait for msiexec to return from the first msiexec call. Check Waiting for msiexec.exe to finish. Or you can try MSI Software Deployment Using Batch File.

Upvotes: 0

Philm
Philm

Reputation: 3674

I answered already a similiar question where it seemed to help:

Windows batch file does not wait for commands to complete

Normally, when you have a batch file with two lines:

call msiexec /x {...} /qb
call msiexec /i "c:\myPath\myProduct.msi" /qb

it should work in the sense that the uninstall waits before install starts.

  • The "call" is important !
  • For uninstalls of previous versions you have to use /x {ProductCode to fill in} instead of /x "filename" . In each case using the product code is safer.
  • To be sure what happens, you can add a pause line between the two and at the end.

If it still seems not to work you have to loop until the product is really uninstalled, wait two seconds and proceed then with an install.

There are several possibilities to find out, if a program is still installed.

Most people would recommend a VB script as the easiest solution, at least these are most known. Here is a VBS snippet from saschabeaumont for an uninstall call from another question: MSI Install Fails because "Another version of this product is already installed"

It mainly finds out the ProductCode of a given productname (part), and starts uninstall, if it fits (be careful about partial matches). You can use it for the same thing and additionally copy the algorithm a second time to ask asynchronously, if the uninstall has already been finished (= product is no longer in list of installed products).

Of course it is possible in other script languages, namely JScript, Powershell and traditional programming languages. It is difficult to do in pure batch scripts- for example you could test the ProductCode registry entry under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, if a product is installed. But only one disadvantage to mention: You have to consider the difference, if batch is started from 32/64 bit subsystem and/or MSI is 32/64 bit. Therefore I would advise instead using VBS instead of a batch (you can call it from the batch with cscript xxx.vbs).

Upvotes: 1

Related Questions