> For the complete documentation index, see [llms.txt](https://wiki.datadike.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.datadike.com/sonar/deploy-operate/install-agent-windows.md).

# Install the agent on Windows

Generate a Windows installer in Agents › Install Agent, run it interactively or silently, and confirm the device reports in Sysadmin.

## What this is and when to use it

**Agents › Install Agent** generates an installer for one client and site. The installer registers the device under that site, installs the SONAR agent service and the remote access agent, and applies the optional features you selected. Use it to onboard a single Windows device or a handful of them. For hundreds of devices, reuse one installer through your software distribution tool, or use a deployment link — see [Deploy agents at scale](https://wiki.datadike.com/sonar/deploy-operate/mass-deployment.md).

## Before you start

* Your role has **Install Agents** in **Admin Center › Roles**. Without it the generate button stays disabled with *You don't have permission for this action*.
* The client and site exist, and your role gives you access to that site. See [Clients and sites](https://wiki.datadike.com/sonar/administration/devices/clients-and-sites.md).
* The device meets [Endpoint requirements](https://wiki.datadike.com/sonar/deploy-operate/requirements.md): Windows 10, Windows 11 or Windows Server 2016 and later, and you have local administrator rights on it.
* The device can reach the SONAR API and remote access addresses on 443/tcp. See [Network requirements](https://wiki.datadike.com/sonar/deploy-operate/network-requirements.md).
* Antivirus and EDR exclusions are in place for `C:\Program Files\Sonar\`, `C:\Program Files\Mesh Agent\` and `C:\ProgramData\Sonar\`.

## Steps

### Generate the installer

1. Open **Agents › Install Agent** from the header, or click **New Agent** on the **Dashboard › Sysadmin** device list. The **Add an agent** panel opens.
2. Choose the **Client** and the **Site**.
3. Under **Operating system**, select **Windows**.
4. Under **Agent type**, select **Workstation** or **Server**.
5. Under **Architecture**, select **64-bit** or **32-bit**, matching the operating system of the device.
6. Under **Optional features**, switch on or off each feature. What each one changes on the device is in the field reference below.
7. Under **Installation method**, choose **Dynamic (.exe)**, **PowerShell** or **Manual**.
8. To limit how long the installer works, switch on **Enable token expiration (hours)** and enter the number of **Hours**.
9. Check the **Target** summary at the bottom of the panel, then click the button for the method you chose:
   * **Download Windows installer (.exe)** downloads `sonar-<client>-<site>-<type>-<architecture>.exe`;
   * **Get Powershell install script** downloads `sonar-<client>-<site>-<type>.ps1`;
   * **View manual setup instructions** opens the **Manual Installation** dialog.

### Run the Dynamic (.exe) installer interactively

1. Copy the file to the device and run it. Accept the elevation prompt.
2. Follow the installer pages. Near the end the agent shows *Installation was successful! Allow a few minutes for the agent to properly display in the RMM*. Click **OK**.
3. When the installer finishes, a **Sonar RMM** status box shows the state of the agent and of the remote access agent.

### Run the Dynamic (.exe) installer silently

Run the file with `/S` from an elevated prompt or from your deployment tool:

```
sonar-<client>-<site>-<type>-<architecture>.exe /S
```

`/S` hides the installer pages. The file carries every setting chosen in the console, so no other argument is needed.

{% hint style="info" %}
Run from a logged-on, interactive session, the agent still shows its final message box and waits for **OK**, even with `/S`. Tools that run the file as Local System in the background, such as a GPO startup script or most software distribution tools, show nothing. For an unattended run inside a user session, use the PowerShell script or the manual command with `-silent`.
{% endhint %}

### Run the PowerShell script

1. Copy the `.ps1` file to the device.
2. In an elevated PowerShell window, run it:

   ```
   powershell -ExecutionPolicy Bypass -File .\sonar-<client>-<site>-<type>.ps1
   ```

The script stops at once with *Sonar RMM Is Already Installed* if the `sonarrmm` service exists. Otherwise it waits for the API address to answer on 443 (up to three attempts, printing *Waiting for network*), adds the SONAR folders to the Microsoft Defender exclusions when Defender is active, downloads the installer, installs it silently and registers the agent with `-silent`, so no message box appears.

### Run the manual command

1. In the **Manual Installation** dialog, click **Download Agent** to download `sonaragent-v<version>-windows-<architecture>.exe`.
2. Click **Copy Command Line**.
3. On the device, open an elevated Command Prompt in the folder that holds the downloaded file.
4. Paste the command, append any **Optional Arguments** you need (for example `-silent` or `-desc "Front desk PC"`), and press Enter.

The command installs the downloaded file silently, waits about ten seconds, then runs the agent's registration with the client, site, type, token and optional features chosen in the console.

## What you should see

On the device, three services when the productivity module is selected, two otherwise:

| Service name               | Display name               | What it is                                                                                                                                                            |
| -------------------------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sonarrmm`                 | Sonar Agent Service        | The SONAR agent. Runs `C:\Program Files\Sonar\sonarrmm.exe -m svc` as Local System                                                                                    |
| `Mesh Agent`               | Mesh Agent                 | The remote access agent, in `C:\Program Files\Mesh Agent\`                                                                                                            |
| `SonarProductivityService` | Sonar Productivity Service | The productivity module, installed only when **Sessions** is on. See [The productivity module](https://wiki.datadike.com/sonar/deploy-operate/productivity-module.md) |

**Sonar**, publisher **DataDike®**, appears in the installed programs list.

In the console, the device appears in **Dashboard › Sysadmin** under its client and site within a few minutes, with **Agent Status** **Online**.

### What the installer changes on the device

| Change                                                                                                                                                                                                                                           | When                           |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------ |
| Windows Update is set not to install updates automatically (`AUOptions` policy under `HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU`), so that patching is driven from SONAR. Uninstalling the agent turns automatic updates back on | Always                         |
| Agent configuration written to `HKLM\SOFTWARE\Sonar`                                                                                                                                                                                             | Always                         |
| Sleep, hibernate, disk and monitor timeouts set to never, lid close action set to do nothing, fast startup turned off                                                                                                                            | **Disable sleep/hibernate** on |
| Windows Remote Desktop enabled, and the Remote Desktop firewall rule group enabled                                                                                                                                                               | **Remote access** on           |
| Firewall rule *ICMP Allow incoming V4 echo request* added                                                                                                                                                                                        | **Ping** on                    |
| Windows location services turned on, so the agent can report the device position                                                                                                                                                                 | **Geolocation** on             |
| Productivity module installed as `SonarProductivityService`                                                                                                                                                                                      | **Sessions** on                |

## How to verify it worked

1. On the device, run `"C:\Program Files\Sonar\sonarrmm.exe"` without arguments. The **Sonar RMM** status box lists **Agent** and **Mesh Agent** with their state. Both must be running. `sc query sonarrmm` gives the same answer from a prompt.
2. In the console, open **Dashboard › Sysadmin**, pick the client, and search for the host name. The row shows **Agent Status** **Online**, the **Client** and **Site** you chose, the **Type** you chose, and today's date in **First Seen**.
3. Select the row. The details panel header shows the agent version, and no **Remote Offline** pill once the remote access agent has connected.
4. In **Reports & Audits › Audits**, an **Agent Install** entry records the new agent with its host name.

## Common errors

| Symptom                                                                                                                                                    | Cause                                                                                         | Fix                                                                                                                                              |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| *This application requires a 64-bit Windows operating system.*                                                                                             | The 64-bit installer was run on 32-bit Windows                                                | Generate the installer again with **Architecture** **32-bit**                                                                                    |
| *Installer token has expired. Please generate a new one.*                                                                                                  | The installer was generated with **Enable token expiration (hours)** and that time has passed | Generate a new installer                                                                                                                         |
| *Old installer detected (version …). Latest version is … Please generate a new installer from the RMM*                                                     | The installer was saved before the SONAR agent version changed                                | Generate a new installer                                                                                                                         |
| A message box reads *Existing installation found*, with **OK** to remove it and **Cancel** to abort                                                        | The device already has an agent                                                               | Click **OK** to uninstall it, then run the installer again. See [Remove agents](https://wiki.datadike.com/sonar/deploy-operate/remove-agents.md) |
| A silent run ends immediately and nothing is installed; the output reads *Existing installation found and must be removed before attempting to reinstall.* | The device already has an agent, or what is left of one                                       | Run `"C:\Program Files\Sonar\uninstall.exe" /S`, then run the installer again                                                                    |
| *Sonar RMM Is Already Installed* (PowerShell)                                                                                                              | The `sonarrmm` service exists                                                                 | Uninstall first, then run the script again                                                                                                       |
| *Unable to connect to server* (PowerShell)                                                                                                                 | 443/tcp to the API address is blocked                                                         | See [Network requirements](https://wiki.datadike.com/sonar/deploy-operate/network-requirements.md)                                               |
| *Unable to download the mesh agent from the RMM.* or *Failed to download mesh agent*                                                                       | The installer could not get the remote access agent through the API address                   | Check connectivity to the API address, then run the installer again                                                                              |
| The generate button is disabled                                                                                                                            | No client or site is selected, or your role lacks **Install Agents**                          | Select both, or ask for the permission                                                                                                           |
| The device is installed but does not appear in Sysadmin                                                                                                    | The agent cannot keep its connection to the API address                                       | See [Troubleshoot agents](https://wiki.datadike.com/sonar/deploy-operate/troubleshooting.md)                                                     |

## Field reference

| Field                               | What it does                                                                                                                              | Accepted values                                | Default                        |
| ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------- | ------------------------------ |
| **Client**                          | Client the device is registered under                                                                                                     | Clients your role can access                   | First client in the list       |
| **Site**                            | Site the device is registered under                                                                                                       | Sites of the chosen client                     | First site of the client       |
| **Operating system**                | Platform of the installer                                                                                                                 | **Windows**, **Linux**, **macOS**              | **Windows**                    |
| **Agent type**                      | Records the device as a workstation or a server. It sets the **Type** column and the default Windows Update schedule of the device        | **Workstation**, **Server**                    | **Workstation**                |
| **Architecture**                    | Processor architecture of the installer                                                                                                   | **64-bit**, **32-bit**                         | **64-bit**                     |
| **Sessions**                        | Installs the productivity module, which reports user activity and sessions and enforces access policies                                   | On, off                                        | On                             |
| **Geolocation**                     | Turns on Windows location services and reports the device position about once an hour                                                     | On, off                                        | On                             |
| **Remote access**                   | Enables Windows Remote Desktop on the device and its firewall rules. The SONAR remote access agent is installed whether this is on or off | On, off                                        | On                             |
| **Ping**                            | Adds a firewall rule so the device answers ping (ICMPv4 echo)                                                                             | On, off                                        | On                             |
| **Disable sleep/hibernate**         | Stops the device from sleeping or hibernating. Shown for **Workstation** only                                                             | On, off                                        | On                             |
| **Installation method**             | Output the console produces                                                                                                               | **Dynamic (.exe)**, **PowerShell**, **Manual** | **Dynamic (.exe)**             |
| **Enable token expiration (hours)** | When on, the installer stops working after the number of hours entered                                                                    | On, off; **Hours** from 1 to 999999            | Off; 24 hours when switched on |

Optional features are fixed at installation. To change them on a device, generate a new installer and reinstall the agent.

### Optional arguments of the manual command

| Argument                                           | What it does                                                                                                                   |
| -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `-log debug`                                       | Verbose output during the install                                                                                              |
| `-silent`                                          | No message boxes during the install                                                                                            |
| `-local-mesh "C:\<folder>\meshagent.exe"`          | Installs the remote access agent from a local file instead of downloading it                                                   |
| `-meshdir "C:\Program Files\<company>\Mesh Agent"` | Folder of an already installed remote access agent with custom branding                                                        |
| `-nomesh`                                          | Does not install the remote access agent. Remote control is then unavailable on the device                                     |
| `-cert "C:\<folder>\ca.pem"`                       | Uses a domain certificate authority                                                                                            |
| `-desc "<text>"`                                   | Sets the device **Description**                                                                                                |
| `-proxy "http://proxyserver:port"`                 | Uses an HTTP proxy. See [Network requirements](https://wiki.datadike.com/sonar/deploy-operate/network-requirements.md#proxies) |

## Related pages

* [Deploy agents at scale](https://wiki.datadike.com/sonar/deploy-operate/mass-deployment.md)
* [Endpoint requirements](https://wiki.datadike.com/sonar/deploy-operate/requirements.md)
* [Network requirements](https://wiki.datadike.com/sonar/deploy-operate/network-requirements.md)
* [The productivity module](https://wiki.datadike.com/sonar/deploy-operate/productivity-module.md)
* [Troubleshoot agents](https://wiki.datadike.com/sonar/deploy-operate/troubleshooting.md)
