Install the agent on Windows
install.ps1 does the same job as the Linux installer, plus what a real Windows service and an entry in Settings > Apps require. Run it as Administrator.
Run the installer
.\install\install.ps1 -BrokerUrl wss://diyar.cogitave.com/api/v1/console/agent -Token <device-secret>For a locally built, unsigned test binary - before a signed release exists, or against the local dev harness from the next unit:
.\install\install.ps1 -BinaryPath .\massar-agent.exe `
-BrokerUrl ws://127.0.0.1:8088/agent -Token dev -SkipSignatureCheckWhat it does, in order
- Preflight. Checks the current principal is in the Administrator role (
WindowsBuiltinRole::Administrator); anything else is a hardDie, since registering a service requires it. - Resolve the binary. Downloads
massar-agent.exefrom the GitHub Release matching-Version(TLS 1.2 pinned via[Net.ServicePointManager]::SecurityProtocol) into a temp working directory, or copies a local-BinaryPathbuild. - Verify the checksum. Compares
Get-FileHash -Algorithm SHA256against the downloaded.sha256sidecar; a mismatch is a hard failure. - Verify Authenticode, unless
-SkipSignatureCheck:Get-AuthenticodeSignaturemust reportValid, or the installer stops before touching anything else. - Stop and remove any prior service. If a
massar-agentservice is already registered, the installer stops it (Stop-Service -Forcewhen it isn't already stopped) and deletes the old registration withsc.exe delete, then pauses a second. Clearing the old service first is what lets a reinstall replace the binary: a running service holds a file lock on the old.exe, so it must be stopped before the new one can be copied into place. - Copy the binary into
$env:ProgramFiles\Massar(or-InstallDir). - Register the service.
New-Service -Name massar-agent -BinaryPathName '"<path>\massar-agent.exe" --service' `
-DisplayName "Massar Remote-Console Agent" -StartupType AutomaticThe --service argument matters: without it, the binary runs as an ordinary console program that never talks to the Service Control Manager, and the start fails with error 1053.
- Store the environment.
MASSAR_BROKER_URL,MASSAR_AGENT_TOKEN,MASSAR_DEVICE_ID, andRUST_LOG=infoare written as a multi-string value under the service's own registry key,HKLM:\SYSTEM\CurrentControlSet\Services\massar-agent\Environment- per-service configuration, not a global machine environment variable that every process would inherit. - Set restart-on-failure.
sc.exe failure massar-agent reset= 86400 actions= restart/5000/restart/5000/restart/5000Three retries, five seconds apart - the same resilience model as the systemd unit's Restart=always.
- Register in Settings > Apps. Writes
HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\massar-agentwithDisplayName "Cogitave Massar", the publisher (Cogitave), the install location, a display icon, and anUninstallStringthat points at a copy ofuninstall.ps1the installer stages inside the install directory. - Start the service and confirm
Get-Service massar-agentreportsRunningbefore declaring success. If it doesn't, the installer dies pointing at the Windows event log rather than leaving you guessing.
NOTE
The installer writes the Settings entry so Massar is removable where people already look. The script's own comment: "Massar must be removable where people already look for it. Without this key it would not appear in Settings/Control Panel at all, and the only way out would be running a script by hand." It copies uninstall.ps1 next to the binary on a best-effort basis (-ErrorAction SilentlyContinue) and points the UninstallString at that copy, so keep uninstall.ps1 beside install.ps1 when you run it.
Details worth knowing about step 10
The Settings > Apps entry is populated from what the installer can learn at install time:
- Version. The installer runs the just-copied
massar-agent.exe --version, which printsmassar-agent <semver>, and stores that first line of output asDisplayVersion. The probe is wrapped intry/catch: if it fails,DisplayVersionis left empty, and the registry loop simply skips empty values rather than writing a blank field. - A registry write must never fail the install. Reading the version is the only such probe, and it cannot abort a machine setup that has otherwise succeeded - the worst case is one missing field in the Apps entry.
Local dev testing
-BinaryPath plus -SkipSignatureCheck is the combination for testing a binary you built yourself, cross-compiled or otherwise, before any release - or for pointing at the loopback broker from the next unit instead of a real Diyar deployment. -SkipSignatureCheck prints a warning every time it's used; it is not meant to be part of a normal install.
Confirm it's running
Get-Service massar-agentThe Status column should read Running. You'll also find the agent listed as Cogitave Massar under Settings > Apps > Installed apps, with the publisher shown as Cogitave and, if the installed binary answered --version, a version string next to it - that's also where you'll go to remove it later.