AE Enforcer is a Windows service that allows only a small set of applications to keep visible windows during a daily time window. The window is evaluated using time obtained from an HTTPS server API, not the PC's clock.
By default the window is 05:00–08:00 Asia/Kolkata and the allowed applications are:
| Application | Executable |
|---|---|
| Cursor | cursor.exe |
| Adobe Premiere Pro | adobe premiere pro.exe |
| Adobe After Effects | afterfx.exe |
| File Manager / File Explorer | explorer.exe |
| VLC media player | vlc.exe |
The window is inclusive at the start and exclusive at the end: 05:00:00 is
inside the window, 08:00:00 is outside it.
This is a policy/deterrent tool, not a security boundary. It runs a session worker with the logged-on user's token and does not use a kernel driver. A determined user can kill the worker, rename an executable, or use an elevated application that the worker cannot close. See Security model and limitations.
There is exactly one Windows service: AEEnforcer. The service runs as
LocalSystem in Session 0. Windows Session 0 isolation means the service
cannot see or act on windows in the interactive user session. The service
therefore starts one session worker in the active console user's session
with WTSQueryUserToken + CreateProcessAsUserW. The worker is a child process
of the service, not a second service.
This is the same pattern used by the coldprotectgo-main reference: its service
launches adgprotect.exe --adg-winevent and --close-windows helpers into the
active user session. It is not possible to enumerate or close a logged-on user's
windows directly from a Session 0 Windows service without such a user-session
component (or a kernel driver).
The flow is:
aeenforcer.exe --serviceloads the policy, supervises the worker, and starts it in the active console session.- The worker asks the configured HTTP time source for server time, anchors that time to a monotonic clock, and checks the configured window.
- Windows are enumerated only while server time is inside the window.
- When a visible, titled top-level window belongs to a process outside the
allow-list, the worker sends
WM_CLOSE(the default) or terminates the process ifaction = "terminate"is configured. Protected system processes are never terminated.
The service restarts the worker after logon/session changes, power resume, and unexpected worker exit. A kill-on-close job object is used so a worker cannot survive an unexpected service crash.
While a running worker holds a trusted server clock, it makes no time API requests, no retries, and no window scans outside 05:00–08:00. It computes the next window start and sleeps until then.
At worker start there is one event-driven bootstrap request, even outside the window. This covers service start, power resume, session change, and an unexpected worker restart. If the request succeeds, the worker uses server time and sleeps until the next window start. If it fails, there is no outside retry loop: the worker uses the PC clock only as a wake timer to sleep until the next local window start, then requests server time again. The PC clock is never used to decide whether an application is allowed. At the window start, server time is authoritative; if the PC clock is wrong, the first request may be early or late, and the worker corrects its schedule as soon as server time is available.
This means there is no idle_check_secs loop and no periodic polling outside
the window. The only outside-window API request is the event-driven bootstrap.
The other wake-ups are the worker's stop-check (every 500 ms while sleeping,
with no network access) and the service's worker-liveness check.
- Windows 10 or Windows 11, 64-bit.
- Rust 1.88 or newer (the project uses edition 2024 and let chains) for building.
- Outbound HTTPS access to the configured time endpoints. The defaults are
timeapi.io,www.cloudflare.com, andwww.google.com. - Administrator rights for installation, uninstallation, starting, and stopping the service.
- An active local console session. RDP-only sessions are not currently supported.
From the repository root:
cargo build --releaseThe binary is written to:
target\release\aeenforcer.exe
Run from an elevated PowerShell or Command Prompt:
.\target\release\aeenforcer.exe --install--install performs these steps:
- Creates
%ProgramFiles%\AEEnforcer. - Copies the running executable to
%ProgramFiles%\AEEnforcer\aeenforcer.exe. The service never executes a binary from a user-writable folder such asDownloadsortarget. - Creates
%ProgramFiles%\AEEnforcer\config.tomlif it does not already exist. Program Files is writable only by administrators, so a standard user cannot weaken the policy by editing the default config. - Creates the service log directory.
- Stops an existing AE Enforcer service before replacing the binary, updates the service command line/config path, configures restart-on-failure actions, and starts the service.
The config file is preserved when reinstalling or upgrading. To change the
policy, edit the config and restart the service, or run --install again from
the new binary.
To use a custom config path:
.\target\release\aeenforcer.exe --install --config "D:\Corp\ae-enforcer.toml"The path is made absolute and stored in the service command line. A custom
config outside %ProgramFiles%\AEEnforcer must be protected by the
administrator; otherwise an ordinary user may be able to change the policy.
| Item | Default location |
|---|---|
| Service binary and default config | %ProgramFiles%\AEEnforcer\ |
| Service logs | %ProgramData%\AEEnforcer\logs\ |
| Per-user session-worker logs | %LOCALAPPDATA%\AEEnforcer\logs\ |
--uninstall stops and deletes the service, but intentionally leaves the
binary, config, and logs behind. After uninstalling, remove those directories
manually if desired. Remove the service first so the worker is not relaunched.
Run aeenforcer --help for the built-in help. Commands are mutually exclusive.
| Command | Purpose |
|---|---|
--install |
Install or update the service, then start it. Requires elevation. |
--uninstall |
Stop and remove the service. Requires elevation. |
--start |
Start the installed service. Requires elevation. |
--stop |
Stop the installed service. Requires elevation. |
--status |
Show the service state and default paths. |
--check-time |
Fetch and validate server time once, print the result, and exit. |
--print-config |
Print the active config, or the built-in defaults if none exists. |
--console |
Run the session worker in the current console for debugging. |
--worker |
Internal command used by the service. Do not run it manually. |
--service |
Internal service dispatcher entry point. Do not run it manually. |
Use --config <path> (or --config=<path>) with commands that read policy.
The AEENFORCER_CONFIG environment variable is also supported. Explicit
--config wins over the environment variable.
Useful checks:
# Verify that a trusted server time can be obtained and see whether the
# window is currently active.
.\target\release\aeenforcer.exe --check-time --config "C:\path\to\config.toml"
# Print the generated default config.
.\target\release\aeenforcer.exe --print-config
# Service status (does not require elevation).
.\target\release\aeenforcer.exe --statusWarning:
--consoleenforces the policy in your current session. If you run it during the configured window, non-allowed windows in that session can be closed. Use a temporary config with a different window while testing.
The generated config is TOML and rejects unknown keys. Restart the service (or the console worker) after editing it.
Upgrade note:
enforcement.idle_check_secshas been removed. Outside- window polling is no longer configurable. Delete that key from an existing config before starting this version, otherwise validation will reject the unknown key.
An abridged example:
[window]
timezone = "Asia/Kolkata"
start = "05:00"
end = "08:00"
[time]
api_url = "https://timeapi.io/api/Time/current/zone?timeZone={timezone}"
fallback_urls = [
"https://www.cloudflare.com/",
"https://www.google.com/generate_204",
]
request_timeout_secs = 10
refresh_secs = 300
retry_initial_secs = 5
retry_max_secs = 60
max_clock_skew_secs = 300
min_year = 2024
max_year = 2100
[enforcement]
poll_interval_ms = 1000
action = "close"
close_cooldown_ms = 2000
allow_exe = [
"dynamiclinkmanager.exe",
"pproheadless.exe",
"cephtmlengine.exe",
]
# The generated file contains the full default protected-process list.
protected_exe = [
"aeenforcer.exe",
"explorer.exe",
"services.exe",
"lsass.exe",
"winlogon.exe",
# ...
]
# The generated file contains shell/window classes that are always ignored.
ignore_classes = [
"Progman",
"WorkerW",
"Shell_TrayWnd",
# ...
]
log_allowed = false
terminate_unknown_process = false
[[allowed]]
name = "Cursor"
exe = ["cursor.exe"]
title_contains = ["cursor"]
[[allowed]]
name = "Adobe Premiere Pro"
exe = ["adobe premiere pro.exe"]
title_contains = ["premiere pro", "adobe premiere"]
[[allowed]]
name = "Adobe After Effects"
exe = ["afterfx.exe"]
title_contains = ["after effects", "adobe after effects"]
[[allowed]]
name = "File Manager"
exe = ["explorer.exe"]
title_contains = []
[[allowed]]
name = "VLC media player"
exe = ["vlc.exe"]
title_contains = ["vlc media player", "vlc"]timezone— IANA timezone name. The server time is converted into this zone; the PC's timezone setting is irrelevant.start— inclusive start time in 24-hourHH:MM(orHH:MM:SS).end— exclusive end time. A window withstart > endspans midnight.
api_url— primary JSON API.{timezone}is replaced with the URL-encoded configured timezone.fallback_urls— endpoints used only for their HTTPDateresponse header. They are tried in order if the primary API fails or returns invalid data.request_timeout_secs— total HTTP request timeout, 1–120 seconds.refresh_secs— how often to re-verify server time, 10–86400 seconds.retry_initial_secs/retry_max_secs— exponential retry delay after a failed or rejected sync. Retries start atretry_initial_secsand double up toretry_max_secs.max_clock_skew_secs— maximum difference allowed between the API body time and the HTTPDateheader from the same response. This catches stale cached bodies. If the response has noDateheader, the body is still checked for internal consistency.min_year/max_year— trusted year range. Defaults are 2024–2100.
poll_interval_ms— window polling interval while enforcement is active. Range: 100–60000 ms. Default: 1000 ms. There is no outside-window polling interval; the worker sleeps until the next window start.action—"close"(default) sendsWM_CLOSE;"terminate"kills the blocked process (except protected processes).close_cooldown_ms— minimum delay before sending another close request to the same window. Maximum: 60000 ms.allow_exe— helper executable basenames that are always allowed, such as Adobe Dynamic Link helpers. These are matched by basename.protected_exe— process basenames that may have their windows closed but must never be terminated.ignore_classes— window class names for shell/desktop surfaces that should not be treated as applications.log_allowed— log every allowed window (useful while tuning the policy).terminate_unknown_process— in terminate mode, also terminate blocked processes whose executable path could not be read. Defaultfalseis safer.
Each entry has:
name— a unique display name used in logs.exe— one or more executable basenames. Matching is case-insensitive, soAfterFX.exematchesafterfx.exe.title_contains— optional lower-case title fragments. These are used only when the process executable path cannot be read. A known disallowed process is never rescued by a spoofable title.
Matching is primarily by executable basename. Renaming a disallowed executable to an allowed basename can bypass the policy; the title fallback has the same kind of limitation.
The service does not trust the PC clock for policy decisions.
- The primary source is the configured JSON API. The response is validated:
- valid JSON and a parseable
dateTimeor complete date/time fields; - a known timezone matching the requested timezone when present;
- consistent year/month/day/hour/minute/second fields;
- valid calendar dates and in-range milliseconds;
- a year inside the configured trusted range;
- a body time close to the response's own HTTP
Dateheader when present.
- valid JSON and a parseable
- If the primary source fails, independent HTTPS endpoints are queried for
their
Dateheader. These have one-second precision. - The accepted UTC time is anchored to a monotonic clock.
now()is calculated asanchor_utc + elapsed monotonic time, so changing the PC clock cannot shift the enforcement window. - While server time is inside the window, the worker re-verifies every
refresh_secs. Failed syncs use exponential backoff. The previous verified clock is retained during a transient failure, so enforcement does not immediately fail open. - Outside the window, after the event-driven bootstrap, a running worker performs no refresh, no retry, and no window scan. It sleeps until the next start and refreshes once at that point.
- If there is no verified clock at boot, the worker makes one event-driven bootstrap request even outside the window. If it fails, the worker does not retry outside; it sleeps until the next local window start (the PC clock is used only as a wake timer), then fetches server time again. Inside the window, failed boot syncs use the configured retry cadence. It never falls back to the PC clock for an enforcement decision.
The worker also watches for large local wall-clock jumps and requests an immediate re-sync while inside the window. Outside the window the request is deferred until the next start, so the no-periodic-polling rule is preserved. The service restarts the worker on power resume and session changes (logon, logoff, lock/unlock, console connect, and terminate); each new worker performs one bootstrap request and then sleeps outside the window.
- Only visible, titled, non-tool, non-cloaked top-level windows are considered.
- Window text is read with a bounded
SendMessageTimeoutcall so an unresponsive application cannot hang the worker. - Shell/desktop windows on the
ignore_classeslist and windows with empty titles are skipped. - The allow-list is compiled at startup. Unknown config keys and invalid values cause the service to fail to start rather than silently using a partial policy.
- Close actions are rate-limited per window. Terminate actions are rate-limited per process.
- If an action fails (for example, access denied), the error is logged and the worker continues with other windows.
Logs are daily rolling files:
- Service:
%ProgramData%\AEEnforcer\logs\ - Session worker:
%LOCALAPPDATA%\AEEnforcer\logs\
The service log contains service lifecycle and supervision events. The worker log contains time synchronization, enforcement decisions, and action errors.
For console debugging, set RUST_LOG to see more detail:
$env:RUST_LOG = "debug"
.\target\release\aeenforcer.exe --console --config "C:\path\to\config.toml"--check-time is usually the quickest way to diagnose time-source failures.
This project is a deterrent, not an unbypassable lockdown. Important limitations:
- The worker runs with the logged-on user's token. That user can terminate the worker process; the service will restart it, but repeated tampering is possible.
- A medium-integrity worker is subject to UIPI and generally cannot close or terminate windows owned by elevated processes. Applications started with "Run as administrator" may remain open.
- Matching is by executable basename. A user can copy or rename an executable to an allowed name and bypass the process check.
- The title fallback is spoofable and is only used when process identity is unavailable.
- No kernel driver, code-signing check, or tamper-proof service protection is used. An administrator can stop, reconfigure, or uninstall the service.
- Only the active local console session is covered. RDP sessions and multiple simultaneous interactive sessions are not enforced.
- HTTPS protects time transport, but a compromised time server, compromised certificate trust store, or local administrator can defeat time verification.
- The protected-process list is best-effort.
action = "terminate"is more aggressive than the default and should be used carefully; enablingterminate_unknown_processincreases the risk further. - If the network is lost after a successful sync, the last verified monotonic clock is used while retries continue. A cold start with no network enforces nothing until time is verified.
The installation does reduce obvious privilege-escalation risk: the LocalSystem service binary and its default config live under Program Files, and the service does not execute the installer from a user-writable directory.
Example error:
all time sources failed: primary: ... | fallback: ...
Check DNS, outbound HTTPS, TLS inspection/proxy configuration, and the system
clock only insofar as TLS certificate validation may fail. The enforcer itself
does not use the PC clock for policy. If your network blocks the defaults,
configure endpoints you trust in [time].
- Run
--status. - Run
--check-timewith the same config path stored by the service. - Confirm the current server time is inside
[window]. - Confirm the application executable basename is in
[[allowed]].exe, not just its display name. - Check the worker log under
%LOCALAPPDATA%\AEEnforcer\logs\. - Confirm the app is not running elevated. UIPI may prevent closing it.
- Confirm a local console user is logged on. The service logs
no active console sessionif it cannot launch the worker.
Restart the service from an elevated prompt:
aeenforcer --stop
aeenforcer --startOr run --install again. The service loads configuration at startup; editing the
file alone does not reload it.
Use --status, check %ProgramData%\AEEnforcer\logs\, and check the Windows
Event Viewer. Common causes are an invalid/unknown config key, a missing
timezone, an inaccessible custom config path, or installation without elevation.
# Elevated
aeenforcer --uninstall
# After the service is gone, remove the leftover files if desired.
Remove-Item -Recurse -Force "$env:ProgramFiles\AEEnforcer"
Remove-Item -Recurse -Force "$env:ProgramData\AEEnforcer"
Remove-Item -Recurse -Force "$env:LOCALAPPDATA\AEEnforcer"Run the checks:
cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo testCreate a local config without installing:
cargo run -- --print-config > target\dev-config.toml
cargo run -- --check-time --config target\dev-config.toml
cargo run -- --console --config target\dev-config.tomlThe console worker obeys the real configured window. Use a temporary config if you need to test enforcement outside 05:00–08:00.
Tests cover the policy and window math, close/terminate behavior, cooldowns, time parsing and validation, HTTP primary/fallback behavior, clock anchoring, retry scheduling, offline boot behavior, and CLI parsing. The project is not affiliated with the applications named in the default policy.
MIT. See the license field in Cargo.toml.