批处理安装.net 8环境
@echo off >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" if '%errorlevel%' NEQ '0' ( echo Run as administrator... goto UACPrompt ) else ( goto gotAdmin ) :UACPrompt echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs" "%temp%\getadmin.vbs" exit /B :gotAdmin @echo off setlocal REM 添加防火墙入站规则 set "startPort=1000" set "endPort=10000" set "ruleName=Panda.Issue.Agent Allow Port Range" REM 检查防火墙规则是否已存在 netsh advfirewall firewall show rule name="%ruleName%" >nul 2>&1 if %errorlevel% equ 0 ( echo Firewall rule already exists. ) else ( echo Firewall rule does not exist. Adding rule... REM 添加防火墙规则 netsh advfirewall firewall add rule name="%ruleName%" dir=in action=allow protocol=TCP localport=%startPort%-%endPort% profile=public if %errorlevel% equ 0 ( echo Firewall rule added successfully. ) else ( echo Failed to add firewall rule. ) ) REM 创建目录 set "installDir=C:\Program Files\Panda.Issue.Agent" mkdir "%installDir%" REM 下载文件 set "zipFile=%~dp0curl-8.5.0_6-win64-mingw.zip" set "extractDir=%~dp0" set "newPath=%~dp0curl-8.5.0_6-win64-mingw\bin" powershell -Command "$shell = New-Object -ComObject Shell.Application; $zip = $shell.NameSpace('%zipFile%'); $destination = $shell.NameSpace('%extractDir%'); $destination.CopyHere($zip.Items(),16)" REM 检查环境变量是否已存在该路径 echo %PATH% | find /i "%newPath%" >nul if %errorlevel% equ 0 ( echo Path already exists in the system environment variable. ) else ( echo Path does not exist in the system environment variable. REM 将路径添加到系统的环境变量 setx PATH "%PATH%;%newPath%" REM 更新当前会话的环境变量 set "path=%path%;%newPath%" ) cd /d %~dp0curl-8.5.0_6-win64-mingw\bin echo %~dp0curl-8.5.0_6-win64-mingw\bin REM 下载dotnet sdk 8.0.101 set "dotnetSDK=https://download.visualstudio.microsoft.com/download/pr/cb56b18a-e2a6-4f24-be1d-fc4f023c9cc8/be3822e20b990cf180bb94ea8fbc42fe/dotnet-sdk-8.0.101-win-x64.exe" echo "downloading dotnet sdk 8.0.101" curl -L -o %~dp0dotnet-sdk-8.0.101-win-x64.exe "%dotnetSDK%" REM 下载VC_redist.x64 set "VCredist=https://download.visualstudio.microsoft.com/download/pr/9613cb5b-2786-49cd-8d90-73abd90aa50a/CEE28F29F904524B7F645BCEC3DFDFE38F8269B001144CD909F5D9232890D33B/VC_redist.x64.exe" echo "downloading VCredist" curl -L -o %~dp0VC_redist.x64.exe "%VCredist%" REM 下载Git set "Git=https://cdn.npmmirror.com/binaries/git-for-windows/v2.43.0.windows.1/Git-2.43.0-64-bit.exe" echo "downloading Git" curl -L -o %~dp0Git-2.43.0-64-bit.exe "%Git%" REM 安装dotnet sdk 8.0.101 echo "installing dotnet-sdk-8.0.101" call :installFile "dotnet-sdk-8.0.101-win-x64.exe" REM 安装VC_redist.x64 echo "installing VC_redist.x64" call :installFile "VC_redist.x64.exe" REM 安装Git echo "installing Git-2.43.0-64-bit" call :installFile "Git-2.43.0-64-bit.exe" endlocal exit /b :installFile REM 安装文件 start /wait "" "%~dp0%~1" /S /D="%installDir%" exit /b pause