From 8fb76030b2e16ea8fecb7d7695f26ae6680d79e8 Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Tue, 22 Apr 2025 19:59:34 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BC=98=E5=8C=96=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E5=BA=93=E4=B8=8B=E8=BD=BD=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DependencySetup_依赖库安装.bat | 73 ++++++++++++++++++++++++++++++---- 1 file changed, 66 insertions(+), 7 deletions(-) diff --git a/DependencySetup_依赖库安装.bat b/DependencySetup_依赖库安装.bat index 602c8e3b10..d8bb38e7a3 100644 --- a/DependencySetup_依赖库安装.bat +++ b/DependencySetup_依赖库安装.bat @@ -2,17 +2,76 @@ chcp 65001 setlocal enabledelayedexpansion +:: 定义ANSI颜色代码 +for /f %%a in ('echo prompt $E^| cmd') do set "ESC=%%a" +set "RESET=%ESC%[0m" +set "GREEN=%ESC%[32m" +set "RED=%ESC%[31m" +set "YELLOW=%ESC%[33m" +set "BLUE=%ESC%[34m" +set "CYAN=%ESC%[36m" +set "WHITE=%ESC%[37m" +set "BOLD=%ESC%[1m" + +:: 初始化错误标志 +set "ErrorOccurred=0" + openfiles >nul 2>&1 if %errorlevel% neq 0 ( - echo 正在获取管理员权限... - echo Obtaining administrator privileges... + echo %YELLOW%正在获取管理员权限...%RESET% + echo %YELLOW%Obtaining administrator privileges...%RESET% powershell -Command "Start-Process cmd.exe -ArgumentList '/c %~dpnx0' -Verb RunAs" exit /b ) -winget install "Microsoft.VCRedist.2015+.x64" --override "/repair /passive /norestart" --uninstall-previous --accept-package-agreements --force -winget install "Microsoft.DotNet.DesktopRuntime.8" --override "/repair /passive /norestart" --uninstall-previous --accept-package-agreements --force +echo. +echo %BLUE%========================================%RESET% +echo %BOLD%%CYAN%正在安装 Microsoft Visual C++ Redistributable%RESET% +echo %BOLD%%CYAN%Installing Microsoft Visual C++ Redistributable%RESET% +echo %BLUE%========================================%RESET% +echo. -echo 运行库修复完成,请重启电脑后再次尝试运行 MAA。 -echo The runtime library repair is complete. Please restart your computer and try running MAA again. -pause +winget install "Microsoft.VCRedist.2015+.x64" --override "/repair /passive /norestart" --uninstall-previous --accept-package-agreements --force +if %errorlevel% neq 0 ( + echo. + echo %BOLD%%RED%错误: Microsoft.VCRedist.2015+.x64 安装失败%RESET% + echo %BOLD%%RED%Error: Microsoft.VCRedist.2015+.x64 installation failed%RESET% + set "ErrorOccurred=1" +) + +echo. +echo %BLUE%========================================%RESET% +echo %BOLD%%CYAN%正在安装 .NET Desktop Runtime 8.0%RESET% +echo %BOLD%%CYAN%Installing .NET Desktop Runtime 8.0%RESET% +echo %BLUE%========================================%RESET% +echo. + +winget install "Microsoft.DotNet.DesktopRuntime.8" --override "/repair /passive /norestart" --uninstall-previous --accept-package-agreements --force +if %errorlevel% neq 0 ( + echo. + echo %BOLD%%RED%错误: Microsoft.DotNet.DesktopRuntime.8 安装失败%RESET% + echo %BOLD%%RED%Error: Microsoft.DotNet.DesktopRuntime.8 installation failed%RESET% + set "ErrorOccurred=1" +) + +echo. +if %ErrorOccurred% equ 0 ( + echo %BOLD%%GREEN%运行库修复完成,请重启电脑后再次尝试运行 MAA。%RESET% + echo %BOLD%%GREEN%The runtime library repair is complete. Please restart your computer and try running MAA again.%RESET% +) else ( + echo %RED%========================================%RESET% + echo %BOLD%%RED%运行库修复过程中出现错误%RESET% + echo %BOLD%%RED%Errors occurred during runtime library repair%RESET% + echo. + echo %YELLOW%您可以尝试手动下载并安装以下组件:%RESET% + echo %YELLOW%You can try to manually download and install the following components:%RESET% + echo. + echo %WHITE%Microsoft Visual C++ Redistributable:%RESET% + echo %CYAN%https://aka.ms/vs/17/release/vc_redist.x64.exe%RESET% + echo. + echo %WHITE%.NET Desktop Runtime 8.0:%RESET% + echo %CYAN%https://aka.ms/dotnet/8.0/windowsdesktop-runtime-win-x64.exe%RESET% + echo %RED%========================================%RESET% +) + +pause \ No newline at end of file