bat批处理切换php版本

为了更自由的对php的环境进行组合,手动安装了apache,mysql和各种版本的php,为了方便软件重启,切换版本,写了一个方便的batch脚本用于管理,代码如下……

@echo off
mode con cols=50 lines=30
color 2
:menu
cls
echo.
echo.
echo AMP管理工具 By Yunxiang.Shaw
echo ==============================
echo = =
echo = 【1】重启 Apache =
echo = =
echo = 【2】重启 Mysql =
echo = =
echo = 【3】启用 php5.3 =
echo = =
echo = 【4】启用 php7.1 =
echo = =
echo = 【5】关闭窗口 =
echo = =
echo ==============================
echo.
echo.
set msg=
set /p user_input=请输入菜单序号:
if %user_input% equ 1 (
set msg=重启Apache
httpd -k restart
)
if %user_input% equ 2 (
set msg=重启MySQL
net stop mysql
net start mysql
)
if %user_input% equ 3 (
set msg=切换至php5.3
del /f D:\amp\Apache24\conf\httpd-phpversion.conf
copy D:\amp\Apache24\conf\httpd-php53.conf D:\amp\Apache24\conf\httpd-phpversion.conf >nul
httpd -k restart
)
if %user_input% equ 4 (
set msg=切换至php7.1
del /f D:\amp\Apache24\conf\httpd-phpversion.conf
copy D:\amp\Apache24\conf\httpd-php71.conf D:\amp\Apache24\conf\httpd-phpversion.conf >nul
httpd -k restart
)
if %user_input% equ 5 exit
echo.
if errorlevel 1 echo %msg%失败!
if errorlevel 0 echo %msg%成功!
echo.
pause
goto menu

将代码保存为.bat或者.cmd文件即可