A quick one today guys, it’s Friday and I’m sure you have beer to drink, so we’ll keep this short!

In my last post on creating WiX windows service installers you might have noticed a glaring omission. If you try to install the service on a box where you don’t have enough permissions to install or start a service then the install will bomb out near the end. It doesn’t cause any real problems, but it would be nicer if it warned you right at the start instead of letting you through all the screens first.

Fear not though, for it is a really easy change. There is a WiX element called Condition, which has its condition statement as its text, and a Message attribute for the message to display on failure. Here are a few examples of things you can do, although there are a loads of other possibilities! These can be placed right after the Package node in your Product.wxs file.

Require Admin Rights

<Property Id="MSIUSEREALADMINDETECTION" Value="1" />
<Condition
  Message="This installer can only be used by admin users."
  >Installed OR (Privileged AND AdminUser)</Condition>

Require .Net 4.0

<PropertyRef Id="NETFRAMEWORK40FULL"/>
<Condition
  Message="This application requires .net version 4.0 or higher."
  >Installed OR NETFRAMEWORK40FULL</Condition>

Require IIS 7

<PropertyRef Id="IISMAJORVERSION"/>
<Condition
  Message="This application requires IIS 7 or higher."
  >IISMAJORVERSION >= "#7"</Condition>

 

And that's it! Try it out.