The project provides utility which allows you to establish/maintain Parental Control for Local Accounts in Windows 10.
LogonHoursManager
is a GUI application to easily change to change the allowed logon hoursLogonHoursService
it a service which monitors the allowed logon hours and locks the session once the time is over
The allowed logon hours are the ones you can set with a command like net user USERNAME /time:M-F,10-18
.
You need VS2019 with v142 toolkit to build the solution.
The project can also be built with other versions of VisualStuido after tuning the properties:
-
Copy
_props\user\_Platform.props.IN
to_props\user\_Platform.props
-
Adjust
PlatformToolset
to specify available/desired toolset:<PropertyGroup Label="Configuration"> <PlatformToolset>v141</PlatformToolset> <!-- VS2017 --> </PropertyGroup>
The application doesn't require any special installation.
- Copy all binaries from the archive into a directory with read-only access to Everyone, so only Administrators can remove or update them (if needed).
- Run
LogonHoursService
from command line (with any permissions) for testing purposes, close its console window after ~5 seconds and examine the log in%TEMP%\LogonHoursService.log
. The log should start with something like this:
2021.11.28 02:31:03,322 [INFO] [2672] wmain: ========================================
2021.11.28 02:31:03,323 [INFO] [2672] wmain: Log initialized successfully
2021.11.28 02:31:03,323 [INFO] [2672] wmain: Version: 1.0.0 Alpha
2021.11.28 02:31:03,323 [INFO] [2672] wmain: Build : Nov 27 2021 20:16:40
2021.11.28 02:31:03,323 [INFO] [2672] wmain: _MSC_FULL_VER: 19.29.30133
- As Administrator install the service by executing
LogonHoursService --install
. - Start the service manually.
- Try setting time restrictions for a local user profile with a command like
net user USERNAME /time:M,12-13
. - Check whether the session of
USERNAME
is locked when the specified time is over (take a look into the service log in%windir%\Temp\LogonHoursService.log
) - If everything works as expected, enable autostart for the service.
You can enable verbose logging by placing a file with name LogonHoursService.exe.log4cpp
(into the directory with the executable) with the content like:
log4cpp.rootCategory=DEBUG
The application writes its log into %TEMP%\LogonHoursService.log
(%TEMP%
is %windir%\Temp
for Local System
account).
Dump files (.dmp
) are very useful when you need to investigate an occasional crash.
Add registry key HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps
(refer to the article Collecting User-Mode Dumps for more details).
After local dumps are enabled, you will be able to find the dump under %LOCALAPPDATA%\CrashDumps
next time the crash happens.
If you're running the service under Local System
account, its dumps are generated under %windir%\System32\config\systemprofile\AppData\Local\CrashDumps
or %windir%\SysWOW64\config\systemprofile\AppData\Local\CrashDumps
(for 32-bit services on 64-bit system)
Both projects have now Address Sanitizer enabled in Debug configuration (refer to <EnableASAN>true</EnableASAN>
in \_props\Cxx.props
), so when running them not from VisualStudio IDE the system may complain about missing clang_rt.asan_dbg_dynamic-i386.dll
(for Win32 platform).
It is enough to copy the required DLL from VisualStudio platform toolset directory (something like C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx86\x86
) to the directory with the executable.
This project is intended to be useful in Windows 10, where you cannot easily establish parental control for Local Accounts.
Though the built-in classic parental control is available in Windows 7/8.1, you still can make use of this project.
(!) For Windows 7/8.1 you may need to install KB2999226, if the system complains about missing api-ms-win-crt-runtime-l1-1-0.dll
:
-
LogonHoursManager
is available
-
DailyRollingFileAppender
is used instead ofRollingFileAppender
- log4cpp package upgrade from
1.1.3.1
to1.1.3.3
- Fixed stack overflow caused by T2A/USES_CONVERSION macro
- Fixed calculation of remaining seconds for a session