New system information custom actions coming soon to WiX v3
The Windows Home Server folks have an SDK for extending the server with what they call “add-ins.” Their deployment sample is written with WiX. I love to see that, so I’m looking into what setup functionality would make a useful WHS extension for WiX. Right now, it doesn’t look like there’s much required – the requirements of a WHS add-in installer are pretty minimal over and above a good installer in general.
One thing they mention is detecting WHS if your add-in requires it. It’s not one of the standard Operating System Properties that MSI provides (yet, at least). The WHS SDK recommends calling the GetVersionEx API function. Clearly, it’s time for a custom action: Enter WixQueryOsInfo.
I wanted to follow the same model as MSI; that is, set a property if the OS running the package is of a particular edition or supports a particular feature. That lets you use them in conditions for features or components that only make sense when the user is running a supported OS or configuration.
As I’d be writing a CA to call GetVersionEx, I looked at what else it could detect that MSI didn’t already support. There were several, though sometimes the MSI naming convention didn’t match how GetVersionEx named them. So I decided to set properties for everything GetVersionEx offered using its naming convention. That way, it’s easy to mentally translate from the GetVersionEx doc to the properties WixQueryOsInfo sets.
Then, while I was in there, I added another CA to do something similar: WixQueryOsDirs sets properties for the “special folders” Windows defines for system and user directories. MSI already supports a long list of System Folder Properties but there are extra ones that Windows supports. For WixQueryOsDirs, I didn’t duplicate the ones MSI already supports.
Using WixQueryOsInfo and WixQueryOsDirs
The CAs are part of WixUtilExtension so you need to link with the “-ext WixUtilExtension” switch. Your WiX source must reference the CAs via their properties, to cause the linker to pull in the DLL and sequencing:
<Product ...>
<PropertyRef Id="WIX\_SUITE\_SINGLEUSERTS" />
<PropertyRef Id="WIX\_DIR\_COMMON_DOCUMENTS" />
</Product>
Note that WixQueryOsInfo and WixQueryOsDirs both always set all the properties that apply, regardless of which you specify via PropertyRef. The PropertyRef just pulls in the CA, the DLL in the Binary table, and InstallExecuteSequence and InstallUISequence scheduling.
Look for OSInfo in the next weekly release of WiX v3.
Here’s the documentation page that’s part of WiX.chm:
OSInfo custom actions
The WixQueryOsInfo and WixQueryOsDirs custom actions in wixca (part of WixUtilExtension) set properties over and above the MSI set for OS product/suite detection and standard directories. Here’s a complete list:
WixQueryOsInfo properties
WIX_SUITE_BACKOFFICE
Equivalent to the OSVERSIONINFOEX VER_SUITE_BACKOFFICE flag.
WIX_SUITE_BLADE
Equivalent to the OSVERSIONINFOEX VER_SUITE_BLADE flag.
WIX_SUITE_COMMUNICATIONS
Equivalent to the OSVERSIONINFOEX VER_SUITE_COMMUNICATIONS flag.
WIX_SUITE_COMPUTE_SERVER
Equivalent to the OSVERSIONINFOEX VER_SUITE_COMPUTE_SERVER flag.
WIX_SUITE_DATACENTER
Equivalent to the OSVERSIONINFOEX VER_SUITE_DATACENTER flag.
WIX_SUITE_EMBEDDEDNT
Equivalent to the OSVERSIONINFOEX VER_SUITE_EMBEDDEDNT flag.
WIX_SUITE_EMBEDDED_RESTRICTED
Equivalent to the OSVERSIONINFOEX VER_SUITE_EMBEDDED_RESTRICTED flag.
WIX_SUITE_ENTERPRISE
Equivalent to the OSVERSIONINFOEX VER_SUITE_ENTERPRISE flag.
WIX_SUITE_MEDIACENTER
Equivalent to the GetSystemMetrics SM_SERVERR2 flag.
WIX_SUITE_PERSONAL
Equivalent to the OSVERSIONINFOEX VER_SUITE_PERSONAL flag.
WIX_SUITE_SECURITY_APPLIANCE
Equivalent to the OSVERSIONINFOEX VER_SUITE_SECURITY_APPLIANCE flag.
WIX_SUITE_SERVERR2
Equivalent to the GetSystemMetrics SM_SERVERR2 flag.
WIX_SUITE_SINGLEUSERTS
Equivalent to the OSVERSIONINFOEX VER_SUITE_SINGLEUSERTS flag.
WIX_SUITE_SMALLBUSINESS
Equivalent to the OSVERSIONINFOEX VER_SUITE_SMALLBUSINESS flag.
WIX_SUITE_SMALLBUSINESS_RESTRICTED
Equivalent to the OSVERSIONINFOEX VER_SUITE_SMALLBUSINESS_RESTRICTED flag.
WIX_SUITE_STARTER
Equivalent to the GetSystemMetrics SM_STARTER flag.
WIX_SUITE_STORAGE_SERVER
Equivalent to the OSVERSIONINFOEX VER_SUITE_STORAGE_SERVER flag.
WIX_SUITE_TABLETPC
Equivalent to the GetSystemMetrics SM_TABLETPC flag.
WIX_SUITE_TERMINAL
Equivalent to the OSVERSIONINFOEX VER_SUITE_TERMINAL flag.
WIX_SUITE_WH_SERVER
Windows Home Server. Equivalent to the OSVERSIONINFOEX VER_SUITE_WH_SERVER flag.
WixQueryOsDirs properties
WIX_DIR_ADMINTOOLS
Per-user administrative tools directory. Equivalent to the SHGetFolderPath CSIDL_ADMINTOOLS flag.
WIX_DIR_COMMON_ADMINTOOLS
All-users administrative tools directory. Equivalent to the SHGetFolderPath CSIDL_COMMON_ADMINTOOLS flag.
WIX_DIR_COMMON_DOCUMENTS
All-users documents directory. Equivalent to the SHGetFolderPath CSIDL_COMMON_DOCUMENTS flag.
WIX_DIR_COOKIES
Per-user Internet Explorer cookies directory. Equivalent to the SHGetFolderPath CSIDL_COOKIES flag.
WIX_DIR_HISTORY
Per-user Internet Explorer history directory. Equivalent to the SHGetFolderPath CSIDL_HISTORY flag.
WIX_DIR_INTERNET_CACHE
Per-user Internet Explorer cache directory. Equivalent to the SHGetFolderPath CSIDL_INTERNET_CACHE flag.
WIX_DIR_PERSONAL
Per-user documents directory. Equivalent to the SHGetFolderPath CSIDL_PERSONAL flag.
To use the WixQueryOsInfo and WixQueryOsDirs custom actions, add PropertyRef elements for the properties above you want to be set and add WixUtilExtension to your link options (a.k.a. the Light command line). For example:
<PropertyRef Id="WIX_SUITE_SINGLEUSERTS" />
<PropertyRef Id="WIX_DIR_COMMON_DOCUMENTS" />
WixUtilExtension automatically schedules the custom actions as needed after the AppSearch standard action.