# Win32 Detection Cheat Sheet

AdminSignal operator template. Keep it next to the Intune portal while you build a Win32 app. Replace every `REPLACE-` value. Test every rule on one device before the app leaves the pilot group.

## The detection contract

Detection decides whether Intune believes the app is installed. Requirement rules decide whether Intune should attempt it. They are different questions — do not use one to answer the other.

- A detection rule must return **installed** only when the app is really there
- A script rule must exit `0` **and** write to STDOUT when the app is present
- A script rule must write **nothing to STDERR** on the success path — STDERR can make detection evaluate as not installed
- If multiple manual detection rules exist, **all of them** must be true

## Registry: check both views

| App bitness | Registry view Intune must read |
| --- | --- |
| 64-bit app | `HKLM:\SOFTWARE\Vendor\App` |
| 32-bit app on 64-bit Windows | `HKLM:\SOFTWARE\WOW6432Node\Vendor\App` |

Test both views on the device before you save the rule:

```powershell
Test-Path "HKLM:\SOFTWARE\Vendor\App"
Test-Path "HKLM:\SOFTWARE\WOW6432Node\Vendor\App"
```

## MSI product code: use the uninstall keys

Do not use `Win32_Product` — it can trigger MSI repair operations. Read the uninstall registry keys instead:

```powershell
$ProductCode = "{PRODUCT-CODE-GUID}"
$Roots = @(
    "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall",
    "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
)

foreach ($Root in $Roots) {
    Get-ChildItem $Root -ErrorAction SilentlyContinue |
        Where-Object { $_.PSChildName -eq $ProductCode } |
        ForEach-Object {
            Get-ItemProperty $_.PSPath |
                Select-Object DisplayName, DisplayVersion, Publisher, InstallDate, PSChildName
        }
}
```

## File detection: test the final file

- [ ] Rule points to the final installed file, not the installer cache
- [ ] File version comparison uses the version format actually present on disk
- [ ] Rule fails on a clean device before install and passes after install
- [ ] Rule fails again after the uninstall command has run
- [ ] A newer version of the app would not satisfy the rule for the old version, and the reverse

A safe custom detection script:

```powershell
$File = "C:\Program Files\Vendor\App\App.exe"

if (Test-Path $File) {
    Write-Output "Detected"
    exit 0
}

exit 1
```

## Return codes Intune understands

| Code | Meaning | What to do |
| --- | --- | --- |
| `0` | Success | Success |
| `3010` | Success, restart required | Soft reboot |
| `1641` | Success, restart initiated | Hard reboot |
| `1618` | Another install is already running | Retry |
| `1603` | Fatal MSI error | Failed — inspect the MSI log |
| `87` | Invalid parameter | Failed — fix the command line |

An unmapped return code reads as failure even when the install worked. Map the vendor's codes in the app before you assign it.

## Install command traps

- [ ] Install command is silent — Microsoft does not support interactive Win32 installers through Intune
- [ ] Paths with spaces are quoted
- [ ] PowerShell is launched in the right bitness: `powershell.exe` from an install command is 32-bit; use `%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\powershell.exe` for 64-bit
- [ ] Install timeout is long enough for the app
- [ ] Install behaviour (System or User) matches what the installer needs to write

## Where the evidence lives

| Log | What it tells you |
| --- | --- |
| `IntuneManagementExtension.log` | IME check-in, policy requests, processing and reporting |
| `AppWorkload.log` | Win32 app deployment activity, install processing and app state |
| `AgentExecutor.log` | PowerShell script execution, including script-based detection |
| `AppActionProcessor.log` | Detection and applicability checks for assigned apps |

All under `C:\ProgramData\Microsoft\IntuneManagementExtension\Logs`. Search them for the app GUID from the Intune URL — the portal status lags the device and does not say which stage failed.

App: REPLACE  
Detection type: REPLACE (MSI / file / registry / script)  
Rule proven on device: REPLACE-DEVICE  Date: REPLACE-DATE
