包含: - furniture-3d-system:Next.js 16 全栈应用(资产中心、产品管理、3D装配动画) - autocad-plugin:AutoCAD 家具导出插件源码 - 资产中心改造:编辑弹窗化、删除功能、Toast反馈、自定义Select组件 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
106 lines
3.7 KiB
PowerShell
106 lines
3.7 KiB
PowerShell
# 家具导出插件 - 一键卸载脚本(PowerShell)
|
||
# 目标:删除当前用户 ApplicationPlugins 下的 bundle,并清理自启动注册/可信路径。
|
||
|
||
$ErrorActionPreference = "Stop"
|
||
|
||
function Write-Step {
|
||
param([string]$Text)
|
||
Write-Host $Text -ForegroundColor Cyan
|
||
}
|
||
|
||
function Remove-TrustedPath {
|
||
param(
|
||
[AllowNull()][string]$Existing,
|
||
[Parameter(Mandatory = $true)][string]$PathToRemove
|
||
)
|
||
|
||
if (-not $Existing) { return $Existing }
|
||
|
||
$normalizedRemove = $PathToRemove.Trim().TrimEnd('\')
|
||
$items = $Existing.Split(';') | ForEach-Object { $_.Trim() } | Where-Object { $_ -ne "" }
|
||
|
||
$kept = New-Object System.Collections.Generic.List[string]
|
||
foreach ($it in $items) {
|
||
$k = $it.Trim().TrimEnd('\')
|
||
if (-not $k.Equals($normalizedRemove, [StringComparison]::OrdinalIgnoreCase)) {
|
||
$kept.Add($it.Trim())
|
||
}
|
||
}
|
||
|
||
return ($kept -join ";")
|
||
}
|
||
|
||
Write-Step "[0/3] 环境检查..."
|
||
|
||
if (Get-Process acad -ErrorAction SilentlyContinue) {
|
||
Write-Host ""
|
||
Write-Host "注意:检测到 AutoCAD 正在运行 (acad.exe)。" -ForegroundColor Yellow
|
||
Write-Host "如卸载失败,请先完全关闭 AutoCAD 后再重试。" -ForegroundColor Yellow
|
||
Write-Host ""
|
||
}
|
||
|
||
$appPlugins = Join-Path $env:APPDATA "Autodesk\ApplicationPlugins"
|
||
$bundleDst = Join-Path $appPlugins "FurnitureExporter.bundle"
|
||
$trustedDir = Join-Path $bundleDst "Contents"
|
||
|
||
Write-Step "[1/3] 删除插件文件..."
|
||
if (Test-Path $bundleDst) {
|
||
try {
|
||
Remove-Item -Path $bundleDst -Recurse -Force
|
||
}
|
||
catch {
|
||
Write-Host ""
|
||
Write-Host "删除失败:$bundleDst" -ForegroundColor Red
|
||
Write-Host "常见原因:AutoCAD 未完全关闭/文件被占用/安全软件拦截。" -ForegroundColor Yellow
|
||
Write-Host "你也可以手动删除该目录后,再运行 卸载.bat 清理注册表。" -ForegroundColor Yellow
|
||
Write-Host ""
|
||
throw
|
||
}
|
||
}
|
||
|
||
Write-Step "[2/3] 清理注册表..."
|
||
|
||
$acadRoot = "HKCU:\Software\Autodesk\AutoCAD\R24.3"
|
||
$curVerObj = Get-ItemProperty -Path $acadRoot -Name CurVer -ErrorAction SilentlyContinue
|
||
$acadCur = $curVerObj.CurVer
|
||
|
||
if ($acadCur) {
|
||
$acadBase = Join-Path $acadRoot $acadCur
|
||
|
||
# Applications 自启动项
|
||
$appKey = Join-Path $acadBase "Applications\FurnitureExporter"
|
||
if (Test-Path $appKey) {
|
||
Remove-Item -Path $appKey -Recurse -Force -ErrorAction SilentlyContinue
|
||
}
|
||
|
||
# TRUSTEDPATHS 移除插件 Contents(只移除我们加的这一项,避免影响其他插件)
|
||
$profilesRoot = Join-Path $acadBase "Profiles"
|
||
$profiles = Get-ChildItem -Path $profilesRoot -ErrorAction SilentlyContinue
|
||
foreach ($p in $profiles) {
|
||
$varsKey = Join-Path $p.PSPath "Variables"
|
||
if (-not (Test-Path $varsKey)) { continue }
|
||
|
||
$vars = Get-ItemProperty -Path $varsKey -ErrorAction SilentlyContinue
|
||
if (-not ($vars.PSObject.Properties.Name -contains "TRUSTEDPATHS")) { continue }
|
||
|
||
$existingTrusted = [string]$vars.TRUSTEDPATHS
|
||
$newTrusted = Remove-TrustedPath -Existing $existingTrusted -PathToRemove $trustedDir
|
||
|
||
if ($existingTrusted -ne $newTrusted) {
|
||
if ([string]::IsNullOrWhiteSpace($newTrusted)) {
|
||
Remove-ItemProperty -Path $varsKey -Name "TRUSTEDPATHS" -ErrorAction SilentlyContinue
|
||
}
|
||
else {
|
||
New-ItemProperty -Path $varsKey -Name "TRUSTEDPATHS" -PropertyType String -Value $newTrusted -Force | Out-Null
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else {
|
||
Write-Host "未检测到 AutoCAD 2024 注册表信息,跳过注册表清理。" -ForegroundColor Yellow
|
||
}
|
||
|
||
Write-Step "[3/3] 完成"
|
||
Write-Host ""
|
||
Write-Host "卸载完成。请完全关闭 AutoCAD 后重新启动。" -ForegroundColor Green
|
||
Write-Host "" |