public/Invoke-OctaStartupManager.ps1

function Invoke-OctaStartupManager {
    <#
        .SYNOPSIS
        Lists startup apps (Win32_StartupCommand) and can disable a Registry-Run-key-based one
        by name. FR-043. Reuses the exact same snapshot + Run Record mechanism every category
        already uses - Undo-OctaRun needs no changes to reverse this.

        Startup-folder-shortcut-based entries are listed but not manageable this phase (no
        existing TargetType represents "a file was moved" - see research.md).
    #>

    [CmdletBinding()]
    param(
        [string]$Disable
    )

    $items = @(Get-CimInstance -ClassName Win32_StartupCommand -ErrorAction SilentlyContinue)

    if (-not $Disable) {
        foreach ($item in $items) {
            $locationType = if ($item.Location -match 'Run') { 'RegistryRun' } else { 'StartupFolder' }
            Write-Host ("{0,-30} {1,-14} {2}" -f $item.Name, $locationType, $item.Command)
        }
        return $items
    }

    $target = $items | Where-Object { $_.Name -eq $Disable } | Select-Object -First 1
    if (-not $target) {
        return [pscustomobject]@{ Status = 'NotFound'; Message = "Startup item not found: $Disable" }
    }
    if ($target.Location -notmatch 'Run') {
        return [pscustomobject]@{ Status = 'Unsupported'; Message = "'$Disable' is a Startup-folder shortcut, not yet manageable by Octa (see research.md)." }
    }

    $regPath = if ($target.Location -match 'HKLM') {
        "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
    }
    else {
        "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run"
    }

    $run = New-OctaRunFolder
    $snapshot = $null
    try {
        $fileName = "reg-{0:N}.reg" -f [guid]::NewGuid()
        $destination = Join-Path $run.Path $fileName
        if (Save-OctaRegistrySnapshot -RegistryPath $regPath -DestinationFile $destination) {
            $snapshot = [pscustomobject]@{ ActionRef = "$regPath|$($target.Name)"; Type = 'Registry'; SnapshotFile = $fileName }
        }
        Remove-ItemProperty -Path $regPath -Name $target.Name -ErrorAction Stop
    }
    catch {
        return [pscustomobject]@{ Status = 'Error'; Message = $_.Exception.Message }
    }

    Save-OctaRunRecord -RunFolder $run.Path -RunRecord ([pscustomobject]@{
            RunId                      = $run.RunId
            Timestamp                  = (Get-Date).ToString('o')
            CategoriesApplied          = @('startup-manager')
            RestorePointStatus         = 'SkippedByUser'
            RestorePointSequenceNumber = $null
            ActionSnapshots            = @($snapshot)
            IrreversibleActionRefs     = @()
            Status                     = 'Completed'
        })

    return [pscustomobject]@{ Status = 'Success'; RunId = $run.RunId }
}