本帖最后由 xwt620 于 2011-8-20 02:32 编辑
这个是我从PHPnow里找到的批处理,可以参考下
Start.cmd@echo off
rem -- http://PHPnow.org
rem -- By Yinz ( MSN / QQ / Email : Cwood@qq.com )
setlocal enableextensions
if exist Pn\Config.cmd pushd . & goto cfg
if exist ..\Pn\Config.cmd pushd .. & goto cfg
goto :eof
:execmd
echo %1
if exist %1 call %1 && goto :eof
if exist %PnCmds%\%1 call %PnCmds%\%1 && goto :eof
echo # 找不到 %1, 请检查 %PnCmds% 或 %CD% 目录.
%pause%
goto :eof
:cfg
call Pn\Config.cmd
if "%php%"=="" exit /b
title 正在启动 Apache 和 MySQL 服务
echo.
call :execmd Apa_Start.cmd
echo.
call :execmd My_Start.cmd
popd
Stop.cmd@echo off
rem -- http://PHPnow.org
rem -- By Yinz ( MSN / QQ / Email : Cwood@qq.com )
setlocal enableextensions
if exist Pn\Config.cmd pushd . & goto cfg
if exist ..\Pn\Config.cmd pushd .. & goto cfg
goto :eof
:execmd
echo %1
if exist %1 call %1 && goto :eof
if exist %PnCmds%\%1 call %PnCmds%\%1 && goto :eof
echo # 找不到 %1, 请检查 %PnCmds% 或 %CD% 目录.
%pause%
goto :eof
:cfg
call Pn\Config.cmd
if "%php%"=="" exit /b
title 正在停止 Apache 和 MySQL 服务
echo.
call :execmd Apa_Stop.cmd
echo.
call :execmd My_Stop.cmd
popd
Apa_Start.cmd@echo off
rem -- http://PHPnow.org
rem -- By Yinz ( MSN / QQ / Email : Cwood@qq.com )
setlocal enableextensions
if exist Pn\Config.cmd pushd . & goto cfg
if exist ..\Pn\Config.cmd pushd .. & goto cfg
goto :eof
:cfg
call Pn\Config.cmd
if "%php%"=="" exit /b
prompt -$g
if not exist %htd_dir%\logs\httpd.pid goto startsvc
echo ____________________________________________________________
echo ^| ^|
echo ^| Apache 似乎已经运行. ^|
echo ^|____________________________________________________________^|
set input=n
set /p input= -^> 继续执行? (y/N)
echo.
if /i "%input%"=="y" goto startsvc
goto end
:startsvc
%php% upcfg(); || %pause% && goto end
%php% chg_port(env('htd_port')); || %pause% && goto end
pushd %htd_dir%
bin\%htd_exe% -k install -n %htd_svc%
set errno=%errorlevel%
bin\%htd_exe% -k start -n %htd_svc%
set /a errno=%errno% + %errorlevel%
popd
if %errno% GTR 0 %pause%
:end
prompt
popd
Apa_Stop.cmd@echo off
rem -- http://PHPnow.org
rem -- By Yinz ( MSN / QQ / Email : Cwood@qq.com )
setlocal enableextensions
if exist Pn\Config.cmd pushd . & goto cfg
if exist ..\Pn\Config.cmd pushd .. & goto cfg
goto :eof
:cfg
call Pn\Config.cmd
if "%php%"=="" exit /b
prompt -$g
if exist %htd_dir%\logs\httpd.pid goto stopsvc
echo ____________________________________________________________
echo ^| ^|
echo ^| Apache 似乎没有运行. ^|
echo ^|____________________________________________________________^|
echo.
:stopsvc
pushd %htd_dir%
bin\%htd_exe% -k stop -n %htd_svc%
set errno=%errorlevel%
bin\%htd_exe% -k uninstall -n %htd_svc%
set /a errno=%errno%+%errorlevel%
popd
if %errno% GTR 0 %pause%
if exist %homedrive%\ZendOptimizer_errors.txt del %homedrive%\ZendOptimizer_errors.txt /q
prompt
popd
My_Start.cmd@echo off
rem -- http://PHPnow.org
rem -- By Yinz ( MSN / QQ / Email : Cwood@qq.com )
setlocal enableextensions
if exist Pn\Config.cmd pushd . & goto cfg
if exist ..\Pn\Config.cmd pushd .. & goto cfg
goto :eof
:cfg
call Pn\Config.cmd
if "%php%"=="" exit /b
prompt -$g
if not exist %myd_dir%\data\%COMPUTERNAME%.pid goto startsvc
echo ____________________________________________________________
echo ^| ^|
echo ^| MySQL 似乎已经运行. ^|
echo ^|____________________________________________________________^|
set /p input= -^> 尝试停止后继续? (y/N)
echo.
if /i "%input%"=="y" goto stopsvc
goto end
:stopsvc
%net% stop %myd_svc%
%myd_dir%\bin\%myd_exe% --remove %myd_svc%
:startsvc
%php% frpl('%myd_dir%\my.ini', '^^(port\s*=)\s*\d+', '$1 %myd_port%');
%myd_dir%\bin\%myd_exe% --install %myd_svc% --defaults-file="%CD%\%myd_dir%\my.ini"
%net% start %myd_svc% || %pause%
:end
prompt
popd
My_Stop.cmd@echo off
rem -- http://PHPnow.org
rem -- By Yinz ( MSN / QQ / Email : Cwood@qq.com )
setlocal enableextensions
if exist Pn\Config.cmd pushd . & goto cfg
if exist ..\Pn\Config.cmd pushd .. & goto cfg
goto :eof
:cfg
call Pn\Config.cmd
if "%php%"=="" exit /b
prompt -$g
if exist %myd_dir%\data\%COMPUTERNAME%.pid goto stopsvc
echo ____________________________________________________________
echo ^| ^|
echo ^| MySQL 似乎没有运行. ^|
echo ^|____________________________________________________________^|
echo.
:stopsvc
%net% stop %myd_svc%
set errlevel=%errorlevel%
%myd_dir%\bin\%myd_exe% --remove %myd_svc%
if not %errlevel%==0 %pause%
prompt
popd
|