java
@echo off
setlocalREM 检查系统是否已经安装了Java
java -version > NUL 2>&1
if %errorlevel% equ 0 (
echo Java已经安装在您的计算机上。
goto end
)REM 下载Java安装程序
set "downloadUrl=https://javadl.oracle.com/webapps/download/AutoDL?BundleId=244551_78a2d868e11c4b47bd32bef84576da64"
set "installerFile=jre-installer.exe"
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%downloadUrl%', '%installerFile%')"REM 安装Java
start /wait %installerFile% INSTALL_SILENT=1 AUTO_UPDATE=0 STATIC=0 WEB_JAVA=0 WEB_ANALYTICS=0 REBOOT=0REM 配置环境变量
set "javaPath=C:\Program Files\Java\jre1.8.0_xxx" REM 此处xxx需要根据实际安装的版本号进行更改
set "path=%javaPath%\bin;%path%"
setx JAVA_HOME "%javaPath%" /M
setx PATH "%path%" /Mecho Java已经成功安装并配置环境变量。
:end
endlocal
python
@echo off
REM 设置默认值
set PYTHON_VERSION=3.9.5
set PYTHON_INSTALL_DIR=C:\Python39REM 下载 Python 安装程序
echo 下载 Python %PYTHON_VERSION% ...
powershell.exe -Command "Invoke-WebRequest -Uri https://www.python.org/ftp/python/%PYTHON_VERSION%/python-%PYTHON_VERSION%-amd64.exe -OutFile python.exe"REM 安装 Python
echo 安装 Python %PYTHON_VERSION% ...
start /wait python.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0 TargetDir=%PYTHON_INSTALL_DIR%
del python.exeREM 配置环境变量
echo 配置环境变量 ...
setx PATH "%PYTHON_INSTALL_DIR%;%PATH%" /M
setx PYTHONPATH "%PYTHON_INSTALL_DIR%\Lib\site-packages" /Mecho 安装完成!
pause
mysql
@echo off
REM 设置默认值
set MYSQL_VERSION=8.0.25
set MYSQL_INSTALL_DIR=C:\Program Files\MySQL\MySQL Server %MYSQL_VERSION%REM 下载 MySQL 安装程序
echo 下载 MySQL %MYSQL_VERSION% ...
curl -L https://dev.mysql.com/get/Downloads/MySQL-Installer/mysql-installer-community-%MYSQL_VERSION%.exe -o mysql.exeREM 安装 MySQL
echo 安装 MySQL %MYSQL_VERSION% ...
start /wait mysql.exe --install-server=mysqld-%MYSQL_VERSION% --service-name=MySQL%MYSQL_VERSION% --config-file=my.ini --enable-named-pipe --nowait --logfile=mysql-install.log
del mysql.exeREM 配置环境变量
echo 配置环境变量 ...
setx PATH "%MYSQL_INSTALL_DIR%\bin;%PATH%" /Mecho 安装完成!
pause
用txt写完后另存为该文件,修改编码为“ASCI” 可以解决中文乱码