master
barrett-land Publish 0.0.42 7b8ee75 2mo ago
@echo off
REM ============================================================================
REM  EMERGENCY ROLLBACK - double-click this if Altium will not start.
REM
REM  Deletes the AdomBridge extension folder and its ExtensionsRegistry.xml entry,
REM  returning Altium to exactly how it was before the extension was installed.
REM  Needs no admin rights and no network. Safe to run twice.
REM
REM  After it finishes, start Altium normally.
REM ============================================================================
setlocal
echo.
echo   Removing the AdomBridge Altium extension...
echo.

powershell -NoProfile -ExecutionPolicy Bypass -Command ^
  "$ErrorActionPreference='Stop';" ^
  "$root = Get-ChildItem 'C:\ProgramData\Altium' -Directory | Where-Object { $_.Name -like 'Altium Designer*' } | Select-Object -First 1;" ^
  "if (-not $root) { Write-Host '  No Altium Designer folder found - nothing to do.'; exit 0 };" ^
  "$ext = Join-Path $root.FullName 'Extensions';" ^
  "$dir = Join-Path $ext 'AdomBridge';" ^
  "$reg = Join-Path $ext 'ExtensionsRegistry.xml';" ^
  "if (Test-Path $dir) { Remove-Item -LiteralPath $dir -Recurse -Force; Write-Host '  removed folder :' $dir } else { Write-Host '  folder already gone' };" ^
  "if (Test-Path $reg) {" ^
  "  Copy-Item -LiteralPath $reg -Destination ($reg + '.bak-remove-' + (Get-Date -Format 'yyyyMMdd-HHmmss')) -Force;" ^
  "  $x = [xml](Get-Content -LiteralPath $reg -Raw);" ^
  "  $n = @($x.SelectNodes('//Item') | Where-Object { $_.GetAttribute('HRID') -eq 'AdomBridge' });" ^
  "  foreach ($i in $n) { [void]$i.ParentNode.RemoveChild($i) };" ^
  "  for ($k=0; $k -lt 5; $k++) { try { $x.Save($reg); break } catch { Start-Sleep -Seconds 2 } };" ^
  "  Write-Host '  removed registry entries :' $n.Count;" ^
  "  $c = [xml](Get-Content -LiteralPath $reg -Raw);" ^
  "  Write-Host '  registry now has' @($c.SelectNodes('//Item')).Count 'items'" ^
  "} else { Write-Host '  no ExtensionsRegistry.xml found' }"

echo.
echo   Done. Start Altium normally.
echo.
pause