This application runs as a persistent user-mode lock agent that:
- Runs in the system tray (no main window)
- Polls a lock file every second
- Shows a full-screen lock UI when the session is locked
- Starts automatically on user login
- Never requires administrator privileges
-
LockFileMonitor.cs
- Polls
%TEMP%\sessionLock.jsonevery 1000ms - Determines lock state based on file content
- Raises events when lock state changes
- Defaults to LOCKED on any error
- Polls
-
LockScreenForm.cs
- Full-screen, borderless, always-on-top form
- Covers all monitors
- Prevents minimize, close, and Alt+Tab
- Shows lock message and branding
-
TrayApplicationContext.cs
- Main application context running in system tray
- Manages lock screen visibility based on monitor events
- Provides tray menu with status and exit option
-
StartupManager.cs
- Manages auto-startup via Windows Registry
- Provides instructions for Scheduled Task alternative
- Best-effort creation of startup entry
-
Program.cs
- Entry point that initializes tray application
- Single-instance enforcement (mutex)
- Global exception handling
- Logging to console and temp file
Location: %TEMP%\sessionLock.json
Format:
{
"Email": "student@example.com",
"SessionStarted": "2026-01-26T10:30:00.000Z",
"Until": "2026-01-25T14:30:00.000Z"
}Lock State Logic:
- File doesn't exist → LOCKED
- Parsing fails → LOCKED
Untilis null/empty → LOCKEDUntil <= DateTime.UtcNow→ LOCKEDUntil > DateTime.UtcNow→ UNLOCKED
- Checks for existing instance (only one allowed)
- Initializes system tray icon
- Starts lock file monitor
- Checks/creates startup persistence entry
- Shows lock screen if currently locked
- Full-screen lock form is shown
- Covers all monitors
- Cannot be minimized or closed
- Always stays on top
- Regains focus if user tries to switch away
- Lock form is hidden
- Application continues running in tray
- Shows "UNLOCKED" status in tray menu
The application automatically attempts to create a registry entry on first run:
Registry Location: HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Key: DocpilotSystemLock
Value: "C:\path\to\DocpilotSystemLock.exe"
This method works without admin rights and is automatically attempted.
If the registry method fails, you can manually create a Scheduled Task:
-
Press
Win+R, type:taskschd.msc, press Enter -
Click "Create Task..." (not "Create Basic Task")
-
General tab:
- Name:
DocpilotSystemLock - Description:
Docpilot System Lock Agent - ✓ Run whether user is logged on or not
- Configure for: Windows 10/11
- Name:
-
Triggers tab:
- Click New...
- Begin the task: At log on
- Specific user: [Your Username]
- ✓ Enabled
-
Actions tab:
- Click New...
- Action: Start a program
- Program/script:
C:\path\to\DocpilotSystemLock.exe - Start in:
C:\path\to\(directory containing the exe)
-
Conditions tab:
- ✗ Uncheck "Start the task only if the computer is on AC power"
-
Settings tab:
- ✓ Allow task to be run on demand
- ✓ Run task as soon as possible after a scheduled start is missed
- If the task fails, restart every: 1 minute
- Attempt to restart up to: 3 times
-
Click OK
$exePath = "C:\path\to\DocpilotSystemLock.exe"
$action = New-ScheduledTaskAction -Execute $exePath
$trigger = New-ScheduledTaskTrigger -AtLogOn -User $env:USERNAME
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -RestartCount 3 -RestartInterval (New-TimeSpan -Minutes 1)
$principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -LogonType Interactive -RunLevel Highest
Register-ScheduledTask -TaskName "DocpilotSystemLock" -Action $action -Trigger $trigger -Settings $settings -Principal $principal -Forceschtasks /create /tn "DocpilotSystemLock" /tr "\"C:\path\to\DocpilotSystemLock.exe\"" /sc onlogon /rl highest /fschtasks /query /tn "DocpilotSystemLock"schtasks /delete /tn "DocpilotSystemLock" /fdotnet builddotnet build -c Releasedotnet publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=trueOutput will be in: bin\Release\net10.0-windows\win-x64\publish\
- Double-click
DocpilotSystemLock.exe - Application will start in system tray (no window)
- Look for the lock icon in the system tray
- Status: Shows current lock state (🔒 LOCKED / ✅ UNLOCKED)
- Exit (Debug only): Exits the application with confirmation
Logs are written to:
- Console output (if running from terminal)
- Debug output (visible in debugger)
%TEMP%\DocpilotSystemLock.log
- Create a lock file with future date:
@"
{
"Email": "test@example.com",
"SessionStarted": "2026-01-27T10:00:00.000Z",
"Until": "2026-01-27T23:59:59.999Z"
}
"@ | Out-File -FilePath "$env:TEMP\sessionLock.json" -Encoding UTF8- Delete or rename the lock file to test locked state:
Remove-Item "$env:TEMP\sessionLock.json"- Create a lock file with past date (should lock immediately):
@"
{
"Email": "test@example.com",
"SessionStarted": "2026-01-27T10:00:00.000Z",
"Until": "2026-01-27T10:00:01.000Z"
}
"@ | Out-File -FilePath "$env:TEMP\sessionLock.json" -Encoding UTF8- ✓ Monitors a lock file in user's temp directory
- ✓ Shows full-screen lock UI when required
- ✓ Auto-starts on user login
- ✓ Runs in user context (no elevation)
- ✗ Does NOT run as a Windows Service
- ✗ Does NOT require administrator privileges
- ✗ Does NOT use session APIs or SYSTEM privileges
- ✗ Does NOT prevent Task Manager (by design, for safety)
- ✗ Does NOT prevent safe mode boot
- ✗ Does NOT prevent uninstallation
- A determined user can kill the process via Task Manager
- A determined user can delete the startup entry
- A determined user can boot into safe mode
- This is intended as a soft lock for honest users, not a security enforcement tool
- Check if startup entry exists:
- Open Registry Editor (
regedit) - Navigate to:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run - Look for
DocpilotSystemLockentry
- Open Registry Editor (
- If not present, create a Scheduled Task (see above)
- Check logs in
%TEMP%\DocpilotSystemLock.log
- Check if lock file exists:
%TEMP%\sessionLock.json - Check if
Untildate is in the past - Check application logs
- Try restarting the application
- The application has no main window by design
- Check system tray for the icon
- Check Task Manager for
DocpilotSystemLock.exeprocess - Check logs for errors
- In Debug builds, right-click tray icon → Exit
- In Release builds without Debug flag, use Task Manager
- This is intentional for deployment
- Build release version with self-contained option
- Copy executable to target machine
- Run the executable once to create startup entry
- Verify startup entry was created
- Test lock/unlock functionality
- Reboot and verify auto-start
- Exit the application (Debug build) or kill process
- Delete startup registry entry or scheduled task
- Delete the executable
- Delete lock file:
%TEMP%\sessionLock.json
- Custom icon support
- Configurable poll interval
- Multiple monitor improvements
- Localization support
- Windows Service version (if required)
- Telemetry and error reporting
- Configuration file support
© 2026 Docpilot. All rights reserved.
For support, contact: support@docpilot.in