# 去掉发布目录里 exe 的“来自网络”标记,减少首次运行时系统弹出的“未知发布者”安全警告。 # 用法: .\tools\unblock-publish.ps1 [-Path artifacts\publish] param( [string]$Path = (Join-Path (Split-Path -Parent $PSScriptRoot) 'artifacts\publish') ) $ErrorActionPreference = 'Stop' if (-not (Test-Path -LiteralPath $Path)) { Write-Host "找不到目录:$Path(先运行 .\build.ps1 -Publish)" exit 1 } $cleared = 0 Get-ChildItem -LiteralPath $Path -Recurse -File -Include *.exe, *.dll | ForEach-Object { $zone = Get-Item -LiteralPath $_.FullName -Stream Zone.Identifier -ErrorAction SilentlyContinue if ($null -eq $zone) { return } Remove-Item -LiteralPath $_.FullName -Stream Zone.Identifier -ErrorAction SilentlyContinue Write-Host "已解除标记:$($_.FullName)" $cleared++ } if ($cleared -eq 0) { Write-Host '发布目录里没有需要解除的网络标记。' } Write-Host '' Write-Host '说明:本程序未做代码签名,因此 Windows 仍可能在首次运行时提示“未知发布者”并请求管理员权限。' Write-Host '这两次提示都来自系统(安全警告 + UAC 提权),程序本身不联网、不安装服务、不写注册表自启项。'