ISWIX, LLC View Christopher Painter's profile on LinkedIn profile for Christopher Painter at Stack Overflow, Q&A for professional and enthusiast programmers

April 01, 2008

Detecting Windows Server 2008 installed with Server Core option

I recently needed to modify an MSI installation to detect when the target system is running a version of Windows Server 2008 installed with the Server Core installation option. Why, you ask? Because several of the UI utilities installed with the product won't work on a system that doesn't have the Windows Explorer user interface installed so I needed to optionally disable the features associated with those utilities when running on a Server Core instance of Windows Server 2008.

To my dismay, I discovered that MSI doesn't natively expose the ProductType values returned by the GetProductInfo Function. [Hey MSI team, how about adding this in 4.5?]

Given this fact, the proper way to detect a Windows Server 2008 OS installed with the Server Core option would be to write a custom action that queries the aforementioned API and sets an MSI property when any of the *_CORE* values are returned by the pdwReturnedProductType parameter (such as PRODUCT_DATACENTER_SERVER_CORE or PRODUCT_ENTERPRISE_SERVER_CORE or PRODUCT_STANDARD_SERVER_CORE or PRODUCT_WEB_SERVER_CORE, etc.).

As Chris pointed out when I discussed this with him, if you're using a vendor tool to create your MSI installation then the tool may have an alternate method of detecting Server Core (InstallShield can do this via an InstallScript CA).

However, if you're not using a vendor tool or if creating a CA to query GetProductInfo isn't desirable in your situation, you can detect a Windows Server 2008 installed with the Server Core option by the fact that the Windows Explorer user interface isn't installed on Server Core.

To do this, add a search for "explorer.exe" located in the %windir% folder (see MSI example table records below). Then use the public property set by your search in combination with the VersionNT and MsiNTProductType MSI private properties to detect Server Core.

AppSearch Table Record:

  • OS_SUPPORTS_UI findWindowsExplorer

DrLocator Table Record:

  • findWindowsExplorer [WindowsFolder] 0

Signature Table Record:

  • findWindowsExplorer explorer.exe 5.0

Conditional Statement (true if Server Core running)

  • VersionNT=600 AND MsiNTProductType>1 AND NOT OS_SUPPORTS_UI

In fact, assuming MS doesn't depricate explorer.exe in a future version [big assumption], just remove the OS version and product type values from the condition and specify 'NOT OS_SUPPORTS_UI' for a condition that should work on both WS2K8 Server Core as well as future versions of Windows w/o UI support).


Futuristics said...

NICE Blog :)

Tim Owers said...

Expanding upon this thread a little, what would be considered the best solution to detecting 2008 R2 (regardless of edition type)?