Endrju
Endrju

Reputation: 2456

How to check if Office >= 2010 is installed?

How to check in WiX (Product.wxs) if Office is installed in version 2010, 2013, 2016, 2019 or later? 2007, 2003 or older should be ignored (as if Office is not installed at all).

I'm aware of this question: C#: How to know whether certain Office 2003 or 2007 application is installed?, but don't know how to check and combine multiple conditions in WiX. I totally can't come up with anything beyond what's in the above question...

Thank you in advance.

Upvotes: 0

Views: 265

Answers (2)

Eugene Astafiev
Eugene Astafiev

Reputation: 49453

You can use a registry search like shown in the following snippet:

<Property Id="OFFICEPATH">
  <RegistrySearch Id="OfficeReg" Root="HKLM" Key="SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot" Name="Path" Type="raw" />
</Property>

<Condition Message="This application requires Microsoft Office 2010. Please install Office then run this installer again.">
      <![CDATA[Installed OR (OFFICEPATH)]]>
</Condition>

Also you may consider using the Windows Installer APIs to find out if the relevant product/package/component codes are present on the machine. These can be done via P/Invoke calls.

Everything depends on which Office editions you need to support. There are Click2Run editions of MS Office that don't add the usual or necessary windows registry keys. In that case you need to have a special case for that, for example, if your add-in is for Outlook, you could check the following path in the windows registry:

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Office\15.0\Common\InstallRoot\Virtual\VirtualOutlook

Read more about that in the Determine whether Outlook is a Click-to-Run application on a computer

Upvotes: 1

Nikolay
Nikolay

Reputation: 12245

I would not do that. There are too many options how office can be installed nowadays. "Office 365" version that is installed with ClickToRun and not MSI as an example (and may use different registry keys), 32 vs 64 bit options, etc. User can even install office after installing your tool, or update office version later.

Instead, you could detect the version in your VSTO tool (use something like Application.Version for this). And simply give some error message if it's not the one your tool supports.

Check out this topic as well for an overview: How to detect installed version of MS-Office?

Upvotes: 2

Related Questions