﻿iControl Agent - autostart setup (run ONCE per PC)
==================================================

If the agent does not start after a reboot, it is almost always because Windows
AUTO-LOGIN is off. A GUI app can only run inside a logged-in desktop session, so
the autostart entry (Run key / Scheduled Task) only fires AFTER a user logs in.
If the PC sits at the Windows sign-in screen, the agent never launches.

FIX (do both):

1. Keep the agent in a STABLE folder - NOT Downloads (it can get cleared).
   e.g. move this whole folder to  C:\iControl\Agent\

2. Enable auto-login + register a robust Scheduled Task. Right-click PowerShell ->
   "Run as administrator", then:

     powershell -ExecutionPolicy Bypass -File setup-autostart.ps1 `
       -ExePath "C:\iControl\Agent\iControl-agent.exe" `
       -AutoLoginUser "User" -AutoLoginPassword "<the-windows-password>"

   (Auto-login stores the password in the registry - a kiosk tradeoff. To set it
    WITHOUT typing the password on the command line, run 'netplwiz' instead and
    uncheck "Users must enter a user name and password".)

3. Reboot to verify the agent starts on its own.

BOOT STRAIGHT INTO THE AGENT (no desktop flash, Senet-style) - optional:
   Add -AsShell to the command above. It replaces the kiosk user's Windows shell
   (HKCU Winlogon\Shell) with the agent, so at logon Windows launches the agent
   directly and the desktop/taskbar never load:

     powershell -ExecutionPolicy Bypass -File setup-autostart.ps1 `
       -ExePath "C:\iControl\Agent\iControl-agent.exe" `
       -AutoLoginUser "User" -AutoLoginPassword "<pwd>" -AsShell

   - Run it AS THE KIOSK USER (elevated) so HKCU is that user's hive.
   - Maintenance: the operator panel's "Exit to Windows desktop" launches explorer.exe
     on demand; stopping the agent (Ctrl+Shift+Q) also brings the desktop back.
   - Undo: re-run with -RestoreShell (or set HKCU Winlogon\Shell back to explorer.exe).
