Click here to Skip to main content
13,247,953 members (49,049 online)
Click here to Skip to main content
Add your own
alternative version


24 bookmarked
Posted 31 Mar 2008

Simple Parental Control Service in C#

, 31 Mar 2008
Rate this:
Please Sign up or sign in to vote.
Windows service in C# which allows to control computer's ON/OFF time: automatically turns computer OFF every day at the desired time


This project helps to create your own parental control service in C#. The current version will shutdown Windows if an unauthorized user (your kid) tries to boot the family PC during blockout period, say from 11 pm to 7 am.


My friend Alexander asked me if I can help him to control his kid's access to the family PC. I did some research on the Internet and found that there are many of those applications available but:

  1. You have to buy them
  2. They are too complicated for use and have too many options which I will never use

So, I decided to write my own application to help him. The idea was just to write a Windows service which will monitor the system clock and shut down the system if blockout time occurs. But an easy way for a kid to fix this is to change the system clock. This operation takes a little effort and could be done by any computer kid. So, our service has to fix the system clock whenever it's changed. To do that, we can use some Internet resources, say well known time saver

Using the Code

The project contains three main parts:

  1. Service Control Part ParentControl.cs, which checks the current system clock against the blockout period.
  2. Internet Time Synchronization Client NTPClient.cs (written by Valer BOCAN
  3. ExitWindows.cs which is just a C# wrapper for ExitWindowsEx API call (original C++ code sample could be found here).

If the service cannot obtain time from the time server, it will shut down the computer as well. By default, the blockout period starts at 11 pm and ends at 7 am. You can specify different numbers as two parameters at the service start time. In the DEBUG version (only!) this service will ask if you want to shut down your PC or not. To make it possible, you have to check the "Allow service to interact with desktop" box when starting the service.

To install the service, you use InstallUtil.exe from the .NET Framework or call it from the command line with argument -i:

ParentalControl -i 

To make the service self installable, I used a technique described in my other article (Windows Service which Kills Unwanted Windows).

Points of Interest

This project could be easily developed for different parental control services depending on what you need.


  • First version uploaded March 31st, 2008


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior) Intel Corp.
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

Questionhow to uninstall it? Pin
Member 1045492116-Mar-14 2:54
memberMember 1045492116-Mar-14 2:54 
Generalparental control web filter Pin
rudychip16-Aug-09 4:03
memberrudychip16-Aug-09 4:03 
GeneralRe: parental control web filter Pin
Pascal Ganaye17-Jun-10 11:16
memberPascal Ganaye17-Jun-10 11:16 
QuestionControl Computer Access Pin
ansar_ansar12-Dec-08 3:22
memberansar_ansar12-Dec-08 3:22 
GeneralZip file link Pin
fwsouthern6-Apr-08 18:56
memberfwsouthern6-Apr-08 18:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171114.1 | Last Updated 1 Apr 2008
Article Copyright 2008 by Victuar
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid