@ECHO OFF
echo 注意事项：服务全部以“.CS.”开头，安装服务将会自动启动，另win2k需有sc.exe。
:start
%~d0
cd %~dp0
TITLE 控制中心
@echo 1、 启动控制台 apache-2.2.14、mysql-5.1.41、php-5.2.12
@echo 2、 启动控制台 apache-2.2.14、mysql-5.1.41、php-5.3.1
@echo 3、 启动控制台 nginx-0.8.31、mysql-5.1.41、php-cgi-5.2.12
@echo 4、 启动控制台 nginx-0.8.31、mysql-5.1.41、php-cgi-5.3.1
@echo 5、 启动控制台 subversion-1.6.6
echo     ----------------------------------------
@echo 11、安装服务 apache-2.2.14、mysql-5.1.41、php-5.2.12
@echo 12、安装服务 apache-2.2.14、mysql-5.1.41、php-5.3.1
@echo 13、删除服务 apache-2.2.14、mysql-5.1.41
@echo 14、安装服务 nginx-0.8.31、mysql-5.1.41、php-cgi-5.2.12
@echo 15、安装服务 nginx-0.8.31、mysql-5.1.41、php-cgi-5.3.1
@echo 16、删除服务 nginx-0.8.31、mysql-5.1.41、php-cgi
@echo 17、安装服务 subversion-1.6.6
@echo 18、删除服务 subversion-1.6.6
echo     ----------------------------------------
@echo 21、打开IE访问http://localhost/
@echo 22、执行php程序片段
@echo 23、启动mysql客户端
@echo 24、执行phpunit（需先调整参数）
@echo 25、执行phpdocumentor（需先调整参数）
@echo 26、查看当前所有服务
@echo 27、查看apache访问日志和错误日志
@echo 28、查看mysql的sql记录

set /p choice=请输入选择:
if %choice%==1 goto choice1
if %choice%==2 goto choice2
if %choice%==3 goto choice3
if %choice%==4 goto choice4
if %choice%==5 goto choice5
if %choice%==11 goto choice11
if %choice%==12 goto choice12
if %choice%==13 goto choice13
if %choice%==14 goto choice14
if %choice%==15 goto choice15
if %choice%==16 goto choice16
if %choice%==17 goto choice17
if %choice%==18 goto choice18
if %choice%==21 goto choice21
if %choice%==22 goto choice22
if %choice%==23 goto choice23
if %choice%==24 goto choice24
if %choice%==25 goto choice25
if %choice%==26 goto choice26
if %choice%==27 goto choice27
if %choice%==28 goto choice28
goto end


:choice1
start /MIN "启动apache-2.2.14、php-5.2.12，按Ctrl+C关闭" /d%~dp0server\php-5.2.12 server\apache-2.2.14\bin\httpd -d ..\apache-2.2.14 -f ..\apache-2.2.14\conf\httpd-php-5.2.12.conf -w
start /MIN "启动mysqld-5.1.41，按Ctrl+C关闭" /d%~dp0server server\mysql-5.1.41\bin\mysqld --defaults-file=mysql-5.1.41\my.ini --console --general_log --general_log_file=../../mysqld-5.1.41.log
cls
echo 前次操作：启动apache-2.2.14、mysqld-5.1.41、php-5.2.12
goto start

:choice2
start /MIN "启动apache-2.2.14、php-5.3.1，按Ctrl+C关闭" /d%~dp0server\php-5.3.1 server\apache-2.2.14\bin\httpd -d ..\apache-2.2.14 -f ..\apache-2.2.14\conf\httpd-php-5.3.1.conf -w
start /MIN "启动mysqld-5.1.41，按Ctrl+C关闭" /d%~dp0server server\mysql-5.1.41\bin\mysqld --defaults-file=mysql-5.1.41\my.ini --console --general_log --general_log_file=../../mysqld-5.1.41.log
cls
echo 前次操作：启动apache-2.2.14、mysqld-5.1.41、php-5.3.1
goto start

:choice3
start /d%~dp0server\nginx-0.8.31 server\nginx-0.8.31\nginx
start /MIN %~dp0server\nginx-0.8.31.bat
start /MIN "启动php-cgi-5.2.12，按Ctrl+C关闭" /d%~dp0server\php-5.2.12 server\php-5.2.12\php-cgi -b 127.0.0.1:9000
start /MIN "启动mysqld-5.1.41，按Ctrl+C关闭" /d%~dp0server server\mysql-5.1.41\bin\mysqld --defaults-file=mysql-5.1.41\my.ini --console --general_log --general_log_file=../../mysqld-5.1.41.log
cls
echo 前次操作：启动nginx-0.8.31、mysqld-5.1.41、php-5.2.12
goto start

:choice4
start /d%~dp0server\nginx-0.8.31 server\nginx-0.8.31\nginx
start /MIN %~dp0server\nginx-0.8.31.bat
start /MIN "启动php-cgi-5.3.1，按Ctrl+C关闭" /d%~dp0server\php-5.3.1 server\php-5.3.1\php-cgi -b 127.0.0.1:9000
start /MIN "启动mysqld-5.1.41，按Ctrl+C关闭" /d%~dp0server server\mysql-5.1.41\bin\mysqld --defaults-file=mysql-5.1.41\my.ini --console --general_log --general_log_file=../../mysqld-5.1.41.log
cls
echo 前次操作：启动nginx-0.8.31、mysqld-5.1.41、php-5.3.1
goto start

:choice5
cd server\subversion-1.6.6
if not exist "svn_repository\trunk" svnadmin create svn_repository\trunk
if not exist "svn_repository\branches" svnadmin create svn_repository\branches
if not exist "svn_repository\tags" svnadmin create svn_repository\tags
start /MIN "启动subversion-1.6.6，按Ctrl+C关闭" svnserve -d -r svn_repository --config-file conf\svnserve.conf --foreground
cls
echo 前次操作：启动控制台 subversion-1.6.6
goto start



:choice11
cd server\php-5.2.12
sc create .CS.apache binpath= "%~dp0server\apache-2.2.14\bin\httpd -k runservice -d %~dp0server\apache-2.2.14 -f %~dp0server\apache-2.2.14\conf\httpd-php-5.2.12.conf" displayname= ".CS.apache" start= auto
net start .CS.apache
sc create .CS.mysql binpath= "%~dp0server\mysql-5.1.41\bin\mysqld --defaults-file=%~dp0server\mysql-5.1.41\my.ini .CS.mysql" displayname= ".CS.mysql" start= auto
net start .CS.mysql
pause
cls
echo 前次操作：安装服务 apache-2.2.14、mysql-5.1.41、php-5.2.12
goto start

:choice12
cd server\php-5.3.1
sc create .CS.apache binpath= "%~dp0server\apache-2.2.14\bin\httpd -k runservice -d %~dp0server\apache-2.2.14 -f %~dp0server\apache-2.2.14\conf\httpd-php-5.3.1.conf" displayname= ".CS.apache" start= auto
net start .CS.apache
sc create .CS.mysql binpath= "%~dp0server\mysql-5.1.41\bin\mysqld --defaults-file=%~dp0server\mysql-5.1.41\my.ini .CS.mysql" displayname= ".CS.mysql" start= auto
net start .CS.mysql
pause
cls
echo 前次操作：安装服务 apache-2.2.14、mysql-5.1.41、php-5.3.1
goto start

:choice13
net stop .CS.apache
sc delete .CS.apache
net stop .CS.mysql
sc delete .CS.mysql
pause
cls
echo 前次操作：删除服务 apache-2.2.14、mysql-5.1.41
goto start

:choice14
sc create .CS.nginx binpath= "%~dp0server\nginx-0.8.31\srvany.exe" displayname= ".CS.nginx" start= auto
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\.CS.nginx\Parameters" /v "Application" /d "%~dp0server\\nginx-0.8.31\\nginx.exe"
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\.CS.nginx\Parameters" /v "AppParameters" /d ""
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\.CS.nginx\Parameters" /v "AppDirectory" /d "%~dp0server\\nginx-0.8.31\\"
net start .CS.nginx
sc create .CS.php-cgi binpath= "%~dp0server\php-5.2.12\srvany.exe" displayname= ".CS.php-cgi" start= auto
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\.CS.php-cgi\Parameters" /v "Application" /d "%~dp0server\\php-5.2.12\\php-cgi.exe -b 127.0.0.1:9000"
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\.CS.php-cgi\Parameters" /v "AppParameters" /d ""
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\.CS.php-cgi\Parameters" /v "AppDirectory" /d "%~dp0server\\php-5.2.12\\"
net start .CS.php-cgi
sc create .CS.mysql binpath= "%~dp0server\mysql-5.1.41\bin\mysqld --defaults-file=%~dp0server\mysql-5.1.41\my.ini .CS.mysql" displayname= ".CS.mysql" start= auto
net start .CS.mysql
pause
cls
echo 前次操作：安装服务 nginx-0.8.31、mysql-5.1.41、php-5.2.12
goto start

:choice15
sc create .CS.nginx binpath= "%~dp0server\nginx-0.8.31\srvany.exe" displayname= ".CS.nginx" start= auto
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\.CS.nginx\Parameters" /v "Application" /d "%~dp0server\\nginx-0.8.31\\nginx.exe"
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\.CS.nginx\Parameters" /v "AppParameters" /d ""
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\.CS.nginx\Parameters" /v "AppDirectory" /d "%~dp0server\\nginx-0.8.31\\"
net start .CS.nginx
sc create .CS.php-cgi binpath= "%~dp0server\php-5.3.1\srvany.exe" displayname= ".CS.php-cgi" start= auto
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\.CS.php-cgi\Parameters" /v "Application" /d "%~dp0server\\php-5.3.1\\php-cgi.exe -b 127.0.0.1:9000"
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\.CS.php-cgi\Parameters" /v "AppParameters" /d ""
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\.CS.php-cgi\Parameters" /v "AppDirectory" /d "%~dp0server\\php-5.3.1\\"
net start .CS.php-cgi
sc create .CS.mysql binpath= "%~dp0server\mysql-5.1.41\bin\mysqld --defaults-file=%~dp0server\mysql-5.1.41\my.ini .CS.mysql" displayname= ".CS.mysql" start= auto
net start .CS.mysql
pause
cls
echo 前次操作：安装服务 nginx-0.8.31、mysql-5.1.41、php-5.3.1
goto start

:choice16
net stop .CS.nginx
sc delete .CS.nginx
taskkill /f /im nginx.exe
net stop .CS.php-cgi
sc delete .CS.php-cgi
net stop .CS.mysql
sc delete .CS.mysql
pause
cls
echo 前次操作：删除服务 nginx-0.8.31、mysql-5.1.41
goto start

:choice17
cd server\subversion-1.6.6
if not exist "svn_repository\trunk" svnadmin create svn_repository\trunk
if not exist "svn_repository\branches" svnadmin create svn_repository\branches
if not exist "svn_repository\tags" svnadmin create svn_repository\tags
sc create .CS.svnserve binpath= "%~dp0server\subversion-1.6.6\svnserve --service -r %~dp0server\subversion-1.6.6\svn_repository --config-file %~dp0server\subversion-1.6.6\conf\svnserve.conf" displayname= ".CS.svnserve" start= auto
net start .CS.svnserve
pause
cls
echo 前次操作：安装服务 subversion-1.6.6
goto start

:choice18
net stop .CS.svnserve
sc delete .CS.svnserve
pause
cls
echo 前次操作：删除服务 subversion-1.6.6
goto start



:choice21
start "%ProgramFiles%\Internet Explorer\iexplore.exe" http://localhost/
cls
echo 前次操作：打开IE访问http://localhost/
goto start

:choice22
start server\php.bat
cls
echo 前次操作：执行php程序片段
goto start

:choice23
start server\mysql.bat
cls
echo 前次操作：启动mysql客户端
goto start

:choice24
start %~dp0server\phpunit-3.4.5\phpunit.bat --bootstrap bootstrap.php --include-path ..\..\src ..\..\src\tests
cls
echo 前次操作：执行phpunit
goto start

:choice25
start %~dp0server\phpdocumentor-1.4.3\phpdoc.bat -f ..\..\src\core.php -d ..\..\src\phpdoc\manual -ed ..\..\src\phpdoc\examples -t ..\..\src\manual -ti "Documentation" -dn Extension -o HTML:Smarty:PHP
cls
echo 前次操作：执行phpdocumentor
goto start

:choice26
start Services.msc
cls
echo 前次操作：查看当前所有服务
goto start

:choice27
start notepad %~dp0server\apache-2.2.14-access.log
start notepad %~dp0server\apache-2.2.14-error.log
cls
echo 前次操作：查看apache访问日志
goto start

:choice28
start notepad %~dp0server\mysqld-5.1.41.log
cls
echo 前次操作：查看mysql的sql记录
goto start
