KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Detecting if the Server is running as a Service
PRODUCT: 4D | VERSION: 13.2 | PLATFORM: Win
Published On: November 28, 2012

The following approach can be used to determine if the 4D Server on Windows is currently running as a service:

  1. Create the following method:
    C_BOOLEAN($0)
    C_TEXT($sysProfile_t)
    $sysProfile_t:="C:\\Windows\\system32\\config\\systemprofile\\"
    $0:=(System folder(User Preferences_User)=$sysProfile_t)

  2. Save the method as UTIL_RunningAsService

  3. Set the method's 'Execute on Server' attribute to true

  4. Use the method like this:
    If (UTIL_RunningAsService )
        // the server is running as a service

    Else
        // the server is not running as a service

    End if

Note: Some testing may be needed as the $sysProfile_t variable may need to be modified to match the system profile if this changes with different operating systems or if the service is running as someone other than the 'Local System'.