Determining if Server Core is Running

Use the GetProductInfo function to retrieve the product information for the current operating system. If Server Core is running, one of three values will be returned by GetProductInfo: PRODUCT_DATACENTER_SERVER_CORE, PRODUCT_ENTERPRISE_SERVER_CORE, or PRODUCT_STANDARD_SERVER_CORE. Calling GetProductInfo is the recommended way to test if Server Core is running.

Another way to test if Server Core is running is to check for the presence of Explorer.exe on the local file system. If Explorer.exe is not present, then Server Core is running. This method can be used if you are using a scripting language.

The following VBScript sample checks for the presence of Explorer.exe on the local file system.

[Visual Basic]

Dim bServerCore, bExplorer

Const strExplorer =  "\explorer.exe"
strRoot = WshEnv("%SYSTEMROOT%")
strExpPath = strRoot + strExplorer

Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FileExists(strExpPath) Then
    'Explorer.exe is present, Server Core is not running
    WScript.Quit (0)
    bServerCore = False                 
    bExplorer = True
Else
    bServerCore = True
    bExplorer = False
End If

See Also

Developing Applications for Server Core

Send comments about this topic to Microsoft

Build date: 2/28/2008