Skip to content

Add iTunes Windows FMA - #50031

Closed
kitzy wants to merge 1 commit into
mainfrom
add-apple-itunes-windows-fma
Closed

Add iTunes Windows FMA#50031
kitzy wants to merge 1 commit into
mainfrom
add-apple-itunes-windows-fma

Conversation

@kitzy

@kitzy kitzy commented Jul 28, 2026

Copy link
Copy Markdown
Member

Related issue: #50020

What this does

Adds iTunes as a Windows Fleet-maintained app. One of the 11 apps split out of #48501 that failed the FMA validator; #50016 shipped the 6 that passed.

Why it was failing

Install and detection were already fine — the validator installed it in ~28s and osquery found iTunes 12.13.10.3 at C:\Program Files\iTunes\. Uninstall was the failure:

20:06:12  INFO  msg="Executing uninstall script for app..." app=iTunes
20:08:17  INFO  msg="Found app: 'iTunes' at C:\Program Files\iTunes\, Version: 12.13.10.3"
20:08:17  ERROR msg="App still present after uninstall (expected no match for version '12.13.10.3' in programs)"

The two-minute gap is the tell: the old script ran the uninstall, then waited a fixed 120 seconds for msiexec and returned regardless. iTunes is a WiX bundle chaining four MSIs (Apple Application Support x86 and x64, Apple Mobile Device Support, Bonjour, and iTunes), so the removal was still in flight when the script exited and reported success.

The fix stops waiting for a fixed interval and waits for the actual outcome:

  • Stop iTunes, iTunesHelper, AppleMobileDeviceService and mDNSResponder first — they hold file locks, and Start-Process -Wait waits for descendants as well as the process itself, so a resident helper would block the script.
  • Resolve the MSI product code and drive msiexec /x <code> /quiet /norestart directly. The registry UninstallString carries no quiet switch, which raises an invisible dialog in session 0 and silently does nothing — the same problem fixed for Google Earth Pro in Add Google Earth Pro as a Windows FMA #50022. If Apple ever registers the burn bundle instead of the MSI, it falls back to running that with /uninstall /quiet /norestart.
  • Wait on the uninstaller with a 480s cap, then poll the Add/Remove Programs entry until it clears (up to 300s) and fail explicitly if it doesn't.

The install script gets the same treatment — it waits for the ARP entry and for msiexec to drain — so an uninstall can't race an install that's still applying its chained MSIs.

Notes

  • /quiet /norestart is the documented Silent switch set from the winget manifest.
  • Clean ARP DisplayName (iTunes), so exact name matching. Publisher Apple Inc..
  • Scope of the uninstall. This removes the iTunes product, which is what the catalog entry and the exists query represent. Apple's companion packages (Apple Application Support, Bonjour, Apple Mobile Device Support) are separate ARP entries shared with other Apple software and are deliberately left in place — same as Windows' own "uninstall iTunes" behavior.
  • Reuses the existing itunes catalog icon and website asset — no new icon needed.
  • Large installer (~200 MB, four chained MSIs). Windows FMAs: 11 apps blocked on install validation (split from #48501) #50020 flagged it as a likely drop on that basis; this PR attempts the fix instead, and the timings above show the install itself is comfortably inside budget.

Checklist for submitter

  • Input data is properly validated, SELECT * is avoided, SQL injection is prevented (using placeholders for values in statements), JS inline code is prevented especially for url redirects, and untrusted data interpolated into shell scripts/commands is validated against shell metacharacters.
  • Timeouts are implemented and retries are limited to avoid infinite loops

Testing

  • FMA CI validator (install → detect → uninstall) passes on the SYSTEM-context Windows runner — run 30317087603 (All checks passed)
  • Generated output verified locally: manifest SHA matches the winget manifest, exists/patched queries reviewed for name + publisher correctness, apps.json is valid JSON with a description filled in.
  • QA'd all new/changed functionality manually

iTunes is a WiX bundle chaining four MSIs, so removal outlives the uninstaller
process. The previous script waited a fixed 120s for msiexec and then returned
while the removal was still in flight, leaving iTunes registered and failing the
validator's post-uninstall check. Wait on the uninstaller itself, then poll the
ARP entry until it actually clears. The install script gets the same treatment so
an uninstall cannot race an install that is still applying its chained MSIs.
Copilot AI review requested due to automatic review settings July 28, 2026 00:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to add (or effectively update) iTunes as a Windows Fleet-maintained app (FMA), primarily by improving the install/uninstall PowerShell scripts to handle WiX/MSI chaining and avoid fixed sleeps by waiting for real completion signals (process exit + ARP polling).

Changes:

  • Added a new Windows iTunes maintained-app entry to apps.json.
  • Added a new maintained-app output manifest under outputs/apple-itunes/windows.json with embedded install/uninstall scripts.
  • Added new Winget input (apple-itunes.json) and corresponding install/uninstall scripts (apple_itunes_*).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
ee/maintained-apps/outputs/apps.json Adds a new iTunes catalog entry (currently introduces a duplicate/conflicting iTunes entry).
ee/maintained-apps/outputs/apple-itunes/windows.json New generated output manifest + embedded scripts for the new slug.
ee/maintained-apps/inputs/winget/scripts/apple_itunes_uninstall.ps1 New uninstall script that resolves MSI product code and polls ARP until cleared.
ee/maintained-apps/inputs/winget/scripts/apple_itunes_install.ps1 New install script that polls but currently requires installer process exit before success.
ee/maintained-apps/inputs/winget/apple-itunes.json New Winget input definition for a new slug/package mapping.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +42 to +53
$elapsed = 0
while (-not $process.HasExited -and ($elapsed -lt $installTimeoutSeconds)) {
Start-Sleep -Seconds $pollSeconds
$elapsed += $pollSeconds
Write-Host "Installing... ($elapsed seconds, registered: $(Test-ITunesRegistered))"
}

if (-not $process.HasExited) {
Write-Host "Installer did not finish within ${installTimeoutSeconds}s."
Stop-Process -Id $process.Id -Force -ErrorAction SilentlyContinue
Exit 1
}
Comment on lines +725 to +731
{
"name": "iTunes",
"slug": "apple-itunes/windows",
"platform": "windows",
"unique_identifier": "iTunes",
"description": "iTunes is a media player and library for music, video, and podcasts that also syncs and backs up iPhone, iPad, and iPod devices."
},
Comment on lines +1 to +8
{
"name": "iTunes",
"slug": "apple-itunes/windows",
"package_identifier": "Apple.iTunes",
"unique_identifier": "iTunes",
"program_publisher": "Apple Inc.",
"install_script_path": "ee/maintained-apps/inputs/winget/scripts/apple_itunes_install.ps1",
"uninstall_script_path": "ee/maintained-apps/inputs/winget/scripts/apple_itunes_uninstall.ps1",
Comment on lines +1 to +12
{
"versions": [
{
"version": "12.13.10.3",
"queries": {
"exists": "SELECT 1 FROM programs WHERE name = 'iTunes' AND publisher = 'Apple Inc.';",
"patched": "SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM programs WHERE name = 'iTunes' AND publisher = 'Apple Inc.' AND version_compare(version, '12.13.10.3') < 0);"
},
"installer_url": "https://secure-appldnld.apple.com/itunes12/047-76416-20260302-fefe4356-211d-4da1-8bc4-058eb36ea803/iTunes64Setup.exe",
"install_script_ref": "7170f396",
"uninstall_script_ref": "42f68f5e",
"sha256": "cea2a74cae3f061eadc11358eeaae9b40cfdea9ec1ee037b47da54a64219e182",
@kitzy

kitzy commented Jul 28, 2026

Copy link
Copy Markdown
Member Author

Closing since we already have an FMA for iTunes

@kitzy kitzy closed this Jul 28, 2026
@kitzy
kitzy deleted the add-apple-itunes-windows-fma branch July 28, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants