SvcEvents Service

by Romain Petges

This service is developed in Borland Delphi 2006 but doesn't use any specific Delphi classes, except the Windows unit for some basic declarations. It should compile also without problems on older Delphi versions.

The NT service is based on a code skeleton provided by Aphex and has been tested on Windows XP Sp2. It should also work on Vista.

What is it?

SvcEvents is a Windows service that runs in the system space and monitors LOGIN, LOGOFF, SHUTDOWN, LOCK and UNLOCK events. In our ZENworks environment, most of our MSI applications are associated to the machine and installed into the Workstation security space. Some applications however, need a forced reboot of the machine before they can be used or even before the environment works correctly. An example is an update to the ZFD Agent which stops services and other stuff and a reboot is required!

Due to the fact that our ZENworks configuration is periodically checking for new applications (user and workstation associations), these aapplications would pre-install immediately when they become available. Using the Requirements in NAL doesn't help so much because the information about a logged-in user is written to the volatile registry key in the current user profile .... workstation security space applications don't have access to this area.

How does it work?

Install the service : SvcEvents /i
Remove the service : SvcEvents /u

All standard NT service operations such as starting and stopping can be performed.

Once you install the service, it autostarts and create a HKLM\Software\.Support key and puts the following value into this key :

Value name : SessionState
Value data : 'LoggedIn' or 'Idle'

'LoggedIn' : This value data appears whenever a user is logged into the machine (LOGIN, LOCK or UNLOCK)

'Idle' : This value data appears when NO user is connected (example : a user generated a LOGOUT or SHUTDOWN session event). If a user unplugs the power cord when he was logged in, then the service deletes the 'LoggedIn' data value and changes it to 'Idle'.

In your NAL application, set the requirements to "HKLM\Software\.Support\SessionState = 'Idle' to push applications when no user is connected.

It doesn't support Terminal Services, only local logins.

The source code with all necessary header files is provided AS IS so you can adapt it to your specific needs. Please read the readme.html in the Win32Api directory for information on how to add the Jedi Library to your project.

Release history

09 October 2007

Added code to automatically detect if a user is logged on service startup. In the NAL requirements page, you now only need to check if the SessionState value in HKLM\Software\.Support equals 'Idle' if you like to deploy applications when no user is logged in.

Best regards,




How To-Best Practice
Comment List