From ad5d0c9b7a21bf334e3aee387b16927f713f3d59 Mon Sep 17 00:00:00 2001 From: shanshanzhong Date: Fri, 7 Nov 2025 04:10:24 -0800 Subject: [PATCH] =?UTF-8?q?fix(copy=5Flibcore.bat):=20=E6=94=B9=E8=BF=9Bjq?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E8=84=9A=E6=9C=AC=E7=9A=84=E5=8F=AF=E9=9D=A0?= =?UTF-8?q?=E6=80=A7=E5=92=8C=E6=B8=85=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将内联的PowerShell命令改为临时脚本文件执行 添加临时文件清理逻辑确保脚本执行后不留残留 --- copy_libcore.bat | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/copy_libcore.bat b/copy_libcore.bat index b1ff5d4..6f64569 100644 --- a/copy_libcore.bat +++ b/copy_libcore.bat @@ -29,20 +29,28 @@ echo ⚠️ 未找到 libcore.dll :install_jq echo 📦 安装 jq... -powershell -Command " - if (!(Get-Command choco -ErrorAction SilentlyContinue)) { - Set-ExecutionPolicy Bypass -Scope Process -Force; - [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; - iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) - } - choco install jq -y - $env:Path = [System.Environment]::GetEnvironmentVariable('Path','Machine') + ';' + [System.Environment]::GetEnvironmentVariable('Path','User') - jq --version -" + +:: 创建临时 PowerShell 脚本文件 +echo if (!(Get-Command choco -ErrorAction SilentlyContinue)) { > install_jq.ps1 +echo Set-ExecutionPolicy Bypass -Scope Process -Force; >> install_jq.ps1 +echo [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; >> install_jq.ps1 +echo iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) >> install_jq.ps1 +echo } >> install_jq.ps1 +echo choco install jq -y >> install_jq.ps1 +echo $env:Path = [System.Environment]::GetEnvironmentVariable('Path','Machine') + ';' + [System.Environment]::GetEnvironmentVariable('Path','User') >> install_jq.ps1 +echo jq --version >> install_jq.ps1 + +:: 执行 PowerShell 脚本 +powershell -NoProfile -ExecutionPolicy Bypass -File install_jq.ps1 if %ERRORLEVEL% neq 0 ( echo ❌ jq 安装失败 + del install_jq.ps1 exit /b 1 ) + +:: 清理临时文件 +del install_jq.ps1 + echo ✅ jq 安装成功 goto :verify