This C# Application is a combination Windows Service and User Interface designed to manage how long a user can use a windows account. The administrator can set daily time limits and the program will monitor the user's time logged in and when they approach the time limit, they are given a warning and eventually forced to log off. The program tries to ignore idle time, so if a user walks away from the computer it does not count against them.
If the user logs back in, they are immediately given the warning and logged off again.
If they are clever and start Task Manager and kill LockDown it automatically restarts.
There is no guarrenty this program is bullet proof and I know of ways to get around it but the source code is available for others to use and enhance. Please give me credit if you use the code.
The only downsideds to a Window's Service is they don't have access to the screen. To allow LockDown to run as both a Service and present a User Interface I run two copies of LockDown. The first copy runs as a Window's Service and monitors the user log in time. The 2nd copy is run in the user's account and present the current time usage status dialog in the lower right and if an authorized administrator, can open the Configuration and History dialogs.
- It is automatically started and available in every user account
- It gets automatically restarted if killed or if it crashes
- It has administrative priviledges and is able to force an account to log off.
Since the two copies of LockDown are run as different users on the same system, they communicate with each other via a shared memory region. The memory is used to send messages back and forth.
Module Description LockDownBg.cs Runs in background as window's service LockDownFg.cs Runs in foreground as User Interface.
A good chunk of LockDown is various code fragments I found on the web or created to support these functions:
Module Description User32DLL List of User Accounts SharedMemory Create shared memory IntSvcInstaller, SvcInstaller Install program as a Window's Service DataMgr Read/write to Registry RunsAs, SensAdviser Manage priviledges and access controls WinExitWindows Force account to exit. WinIdel Measure Idle time.
Here is a list of all the available command line options:
-about Tell everyone about the author and program version -install Install LockDown as a Windows Service -uninstall Uninstall LockDown Windows Service.
The dialog and the icon have a context menu. The full menu is available to the administrator uesrs. Via the menu you can open the configuration dialog.
The history dialog has options to export the values as ".csv" it you want to use Excel to generate graphs, etc.
Lastly there is a built-in alarm clock. This dialog is busy and has several options to set the time or period and what kind of event to fire when the alarm target is reached, such as play a 'wav' sound file, display and image or animated GIF and/or run a program.