Deploying Onagre Agent on Windows (Service via sc.exe)
This guide shows how to install the Onagre Agent as a Windows Service using the Service Control Manager (sc.exe). Once installed, the agent runs in the background, starts automatically on boot, and reports to the Onagre platform.
Requirements - Windows Server 2012/2016/2019/2022 - An Agent Token from the Onagre platform - Outbound HTTPS connectivity to the Onagre API (through your proxy if applicable)
Download the Agent
The Onagre Agent is available for multiple architectures. Use the appropriate command for your system to download and install the agent:
Create a folder for the agent and place the binary there. The examples below use:
If your organization uses software distribution (SCCM, Intune, etc.), push the binary to the target path with correct permissions.
Permissions (recommended)
mkdir "C:\Program Files\Onagre"
rem Grant Administrators full control and tighten inheritance if needed
icacls "C:\Program Files\Onagre" /inheritance:r
icacls "C:\Program Files\Onagre" /grant Administrators:(OI)(CI)F
Copy agent.exe into this folder.
Provide the Agent Token (Environment Variable)
The agent reads its token from the TOKEN environment variable. Set a system-wide environment variable so the Windows Service can inherit it:
Note: You must open a new Administrator command prompt after setting the variable so the updated environment is visible to subsequent commands.
Create the Windows Service
Use sc.exe to register the agent as a Windows Service. The simplest configuration runs under LocalSystem and starts automatically.
sc.exe create OnagreAgent ^
binPath= "\"C:\\Program Files\\Onagre Agent\\agent.exe\"" ^
start= auto ^
DisplayName= "Onagre Agent"
Start the service:
Check status:
You can also use Services (services.msc) to confirm that the service is running.
Optional: Run Under a Dedicated Service Account
For environments with stricter separation of duties, you can run the agent under a domain or local account that has only the permissions it needs.
- Create or choose the account (e.g.,
DOMAIN\\svc-onagre). - Grant Read & Execute on
C:\Program Files\Onagre\to that account. - Ensure the account can reach the network resources the agent must check.
- Update the service to use this account:
If you rotate the password, repeat the
sc.exe configcommand.
Verify Connectivity
- Confirm the service is Running (
sc query OnagreAgent). - In the Onagre web UI, the agent should appear online after a short delay.
- If a proxy is required, configure it globally at the OS level or for the service account.
Logs & Diagnostics - Check Event Viewer → Windows Logs → Application for entries from the agent - If you temporarily run the agent interactively to test, open an elevated prompt and run:
Updating the Agent
- Stop the service:
- Replace
agent.exewith the new version (keep the same path). - Start and verify:
For enterprise rollouts, distribute the updated binary with your software deployment tool.
Managing the Service
- Status
- Restart
- Disable auto-start
- Remove service (uninstall)
Firewall & Proxy Notes
- Ensure outbound HTTPS is allowed from the host (to the Onagre platform endpoints).
- If your environment enforces a proxy, configure it for the service account or system-wide. Validate with
netsh winhttp show proxyand set withnetsh winhttp set proxyif needed.
Troubleshooting
- Service fails to start
- Verify
TOKENis set at the machine level:reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v TOKEN - Confirm the path in
binPathis correct and quoted properly - Check Event Viewer for startup errors
- Agent not visible in UI
- Verify outbound network access; confirm any proxy settings
- Re-check the
TOKENvalue; restart the service after changes - Permission errors
- If running under a service account, ensure it has Read & Execute on the agent folder and access to any monitored resources
Summary
You’ve installed the Onagre Agent as a native Windows Service using sc.exe. The service starts automatically, inherits the TOKEN from the system environment, and reports to the Onagre platform. Keep the binary updated and monitor logs for healthy operation.