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