# Allow the Windows guest agent

Smart App Control, Defender, or your organization's policy can block the Windows guest agent, which isn't signed.

## Where the guest agent is

The guest agent runs commands, copies files, reads Windows controls, and installs drivers. It runs as the service `OSMatesAgent` from `C:\Program Files\OSMates\osmates-agent.exe`, and Windows reports its signature as `NotSigned`.

Windows Setup installs it, or in an imported machine, the OSMATES disc. OSMates replaces an older guest agent at each start, so its hash changes with every release.

## See which guest agent a machine has

1. In File Explorer, open `C:\Program Files\OSMates`.
2. Open **Properties** for `osmates-agent.exe`, then click **Details**.
3. Read **Product version**, the OSMates release.

To check the version and signature in PowerShell:

```powershell
(Get-Item 'C:\Program Files\OSMates\osmates-agent.exe').VersionInfo |
    Format-List ProductName, ProductVersion, FileVersion, OriginalFilename
Get-AuthenticodeSignature 'C:\Program Files\OSMates\osmates-agent.exe'
```

## Check Smart App Control

1. In Windows, open **Windows Security**.
2. Choose **App & browser control > Smart App Control settings**, and read the state.

| State | Effect on the guest agent |
|---|---|
| Evaluation | Nothing is blocked. Windows can switch to On or Off later. |
| On | The guest agent can be blocked. |
| Off | Smart App Control doesn't block it. Other policies and antivirus still apply. |

A blocked guest agent stops commands, file copies, control reading, and its own updates in that machine. Windows, its display, and the power button keep working.

As administrator, `citool.exe -lp` shows the state too: `VerifiedAndReputableDesktopEvaluation` is Evaluation, and `VerifiedAndReputableDesktop` is On. See Microsoft's [Smart App Control overview](https://learn.microsoft.com/en-us/windows/apps/develop/smart-app-control/overview).

### Turn Smart App Control off

Smart App Control has no exception for one app, and OSMates never changes it. In **Smart App Control settings**, choose **Off**. Whether you can turn it on again depends on your Windows version, as Microsoft's [Smart App Control FAQ](https://support.microsoft.com/en-us/windows/security/threat-malware-protection/smart-app-control-frequently-asked-questions) explains.

## If Defender reports the guest agent

Defender scans the guest agent when it's written and when it starts.

1. In PowerShell, run `Get-MpThreatDetection` to see the detection.
2. Submit the file as a false positive at [Microsoft Security Intelligence](https://www.microsoft.com/wdsi/filesubmission).

### Add a Defender exclusion

An exclusion stops Defender scanning the folder, which lowers protection. It doesn't bypass Smart App Control or App Control for Business. OSMates never adds one. Only administrators can write to the folder.

To add one in PowerShell as administrator:

```powershell
Add-MpPreference -ExclusionPath 'C:\Program Files\OSMates'
```

Or choose **Windows Security > Virus & threat protection > Manage settings > Exclusions**.

## Allow the guest agent in a domain or with Intune

### Turn off Smart App Control on managed machines

Set the DWORD `VerifiedAndReputablePolicyState` to `0` under `HKLM\SYSTEM\CurrentControlSet\Control\CI\Policy`, then run `CiTool.exe -r`. See Microsoft's [Application Control guidance](https://learn.microsoft.com/en-us/windows/security/application-security/application-control/app-control-for-business/appcontrol).

### Add an App Control for Business rule

An enforced App Control policy needs a folder rule for the guest agent. A hash rule breaks at every release, and the folder also covers update copies. To add the rule to an existing policy:

```powershell
$rule = New-CIPolicyRule -FilePathRule '%OSDRIVE%\Program Files\OSMates\*'
Merge-CIPolicy -PolicyPaths .\policy.xml -OutputFilePath .\policy.xml -Rules $rule
```

To make a supplemental policy with the same `$rule` instead, the base policy needs rule option 17:

```powershell
New-CIPolicy -MultiplePolicyFormat -Rules $rule -FilePath .\osmates.xml
Set-CIPolicyIdInfo -FilePath .\osmates.xml -SupplementsBasePolicyID '<base policy ID>'
```

Microsoft explains [file-path rules](https://learn.microsoft.com/en-us/windows/security/application-security/application-control/app-control-for-business/design/select-types-of-rules-to-create#more-information-about-filepath-rules) and [multiple policies](https://learn.microsoft.com/en-us/windows/security/application-security/application-control/app-control-for-business/design/deploy-multiple-appcontrol-policies).

### Deploy the policy

In Intune, open **Endpoint security > App Control for Business** and create a policy. Under **Configuration settings**, choose **Enter xml data** and upload the XML. Group Policy takes only the single-policy format, as Microsoft's [deployment guide](https://learn.microsoft.com/en-us/windows/security/application-security/application-control/app-control-for-business/deployment/deploy-appcontrol-policies-using-group-policy) says.

### Configure a Defender exclusion centrally

Exclude `C:\Program Files\OSMates` in your management tool.

| Tool | Setting |
|---|---|
| Intune | **Endpoint security > Antivirus**, a Microsoft Defender Antivirus exclusions profile, **Excluded paths** |
| Group Policy | **Computer Configuration > Administrative templates > Windows components > Microsoft Defender Antivirus > Exclusions > Path Exclusions**, with the path as the value name and `0` as the value |

See [Configure custom exclusions](https://learn.microsoft.com/en-us/defender-endpoint/microsoft-defender-antivirus-exclusions-configure).

## Remove the guest agent

Without the guest agent, OSMates can't run commands, copy files, or read controls in that machine.

1. Open a Windows terminal as administrator.
2. Stop and delete the service:

   ```powershell
   sc.exe stop OSMatesAgent
   sc.exe delete OSMatesAgent
   ```

3. Delete `C:\Program Files\OSMates`.
