Skip to content

A self-healing camera wall: Agent DVR kiosk + watchdog on Windows

PowerShell scripts that open Agent DVR full-screen on each monitor and automatically fix frozen video, Retry pop-ups and error pages. Download and adapt.

advancedUpdated 2026-11-02

Agent DVR is a free-for-local-use video surveillance server with a web interface. Putting its live view on a wall-mounted screen is easy. Keeping it there for weeks is not. Video streams freeze while the page looks fine, Retry pop-ups pile up after the server restarts, and after a power cut the browser can sit on a “Can’t reach this page” error forever.

These scripts come from a real home lab: two monitors on a small Windows PC showing Agent DVR running in Docker on another machine. Network addresses and account details have been replaced with placeholders.

Download the set: Launch-AgentDVR.ps1 · Watchdog-AgentDVR.ps1 · Keeper-AgentDVR.ps1 · Refresh-AgentDVR.ps1 · Pause-Watchdog.ps1 · Resume-Watchdog.ps1 · Install-Watchdog.ps1

The pieces

ScriptRunsJob
Launch-AgentDVR.ps130 s after sign-inOpens one full-screen Microsoft Edge app window per monitor, each pointed at an Agent DVR live view. Each window gets its own profile folder and a remote-debugging port (9222, 9223, …) so the watchdog can inspect it.
Watchdog-AgentDVR.ps1All the time, in the backgroundEvery 10 seconds it looks inside each window and fixes problems (see below).
Keeper-AgentDVR.ps11 min after sign-in, then every 5 minWatches the watchdog. It starts it if it isn’t running, and kills and restarts it if it hasn’t checked in for 2 minutes.
Refresh-AgentDVR.ps1When the watchdog asksThe “hard restart”: it closes only the kiosk Edge windows (found by their EdgeKiosk profile path) and re-runs the launcher.
Pause-Watchdog.ps1 / Resume-Watchdog.ps1By handPause blocks hard restarts for 4 hours while you work on the screen (it expires on its own). Resume ends the pause early.

What the watchdog detects

The watchdog talks to each Edge window through the Chrome DevTools Protocol, the same interface browser developer tools use. It doesn’t take screenshots. Instead it runs a small piece of JavaScript in the page that:

  1. Retry pop-up: looks for a visible button or link whose label contains the word “Retry” and clicks it. If Retry keeps coming back (3 times in 2 minutes), it first checks the Agent DVR server is answering, then reloads the page. If that doesn’t stick either, it escalates to a hard restart.
  2. Silent freeze: draws the largest <canvas> on the page (the video) into a 192×108 copy, hashes the pixels and compares the hash with the last check. If the picture stays unchanged for three checks in a row (about 30 s), it checks the Agent DVR server is answering and then reloads the page. Freezing again within 3 minutes of a reload triggers a hard restart.
  3. Not on the camera page at all: if there’s no video canvas for 6 checks (about a minute), for example because Edge is showing an error page after an outage, it navigates back to the camera URL, but only once the server answers again.

Separately, if the watchdog can’t reach a window’s debugging port or find its Agent DVR page 4 checks in a row, it asks for a hard restart.

Safety rails keep it from thrashing:

  • Hard restarts wait at least 10 minutes between each other, and none happen while the watchdog is paused.
  • Minimized or hidden windows are skipped by the freeze check.
  • Blank or unreadable video turns freeze detection off for that window, so a dark camera at night doesn’t trigger reloads.
  • Every decision is written to C:\Scripts\agentdvr-watchdog-log.txt, which rotates at 5 MB.

Install

  1. Copy all the scripts into C:\Scripts on the PC that drives the screens.

  2. Open Launch-AgentDVR.ps1 and Watchdog-AgentDVR.ps1 and set $AgentDvr to your server’s address, for example http://192.168.1.50:8090. Use the same value in both.

  3. Optionally, in Launch-AgentDVR.ps1, change viewIndex=0 / viewIndex=1 to pick which Agent DVR layout each monitor shows. Monitors are matched top to bottom.

  4. Signed in as the user who will be shown on the screens, open PowerShell as administrator and run:

    powershell -ExecutionPolicy Bypass -File C:\Scripts\Install-Watchdog.ps1

    This registers two scheduled tasks for that user: AgentDVR-DualScreen (the launcher) and AgentDVR-Watchdog (the keeper, which starts the watchdog).

  5. Sign out and back in. The screens should open within about 30 seconds. Check the log to watch it work:

    Get-Content C:\Scripts\agentdvr-watchdog-log.txt -Wait -Tail 20

After installing, open Task Scheduler, select the AgentDVR-Watchdog task and check its Triggers tab. The time trigger should show “repeat every 5 minutes” with no end. If yours shows an end time, edit the trigger and set the duration to Indefinitely.

To test safely, run Watchdog-AgentDVR.ps1 -DryRun -ShowAll in a PowerShell window. It logs what it would do without clicking or reloading anything.

Adapting it to your setup

  • One monitor, or three: add or remove URLs in $urls (launcher) and the matching ports in $Ports / $HomeUrls (watchdog). Ports are 9222 + the monitor’s position, starting from 0.
  • A different web-based NVR or dashboard (Blue Iris web UI, Frigate, Home Assistant, Grafana): the freeze detector works on any page that draws video into a <canvas>. Change the two :8090 URL matches in the watchdog ('*:8090*' and 'http*:8090*') to your server’s port, and change the retry regular expression to whatever your page’s reconnect button says. Pages that use <video> elements need the JavaScript to sample the video element instead of a canvas.
  • Less aggressive: raise $FreezeChecks (checks before a reload) or $IntervalSec (seconds between checks).
  • Night-time dark cameras: $MinLit sets how many bright sample values (colour channels above near-black) the 192×108 copy needs before it counts as real video; below that, freeze detection is switched off for that window. Raise it if dark scenes still cause reloads.

Security notes

  • Debugging port: the remote-debugging port lets anything on that PC control those Edge windows. Chromium browsers listen on 127.0.0.1 by default, so it isn’t reachable from your network. Don’t change that, and don’t sign those kiosk profiles into any accounts.
  • Execution policy: the scheduled tasks use -ExecutionPolicy Bypass for these specific files only. Microsoft notes that execution policy is a safety feature to prevent accidental script runs, not a security boundary. Keep C:\Scripts writable only by administrators.

Sources