@echo off
title 思迈维修业务通-安装程序 (C)2008 OECSM.COM

set CURRENT_DIR=%cd%
IF NOT EXIST "%CURRENT_DIR%\php5\php.exe" set /p CURRENT_DIR=请输入系统安装路径(如: D:\oecsm)：
IF NOT EXIST "%CURRENT_DIR%\php5\php.exe" echo 安装路径不存在,确认安装路径输入正确。
IF NOT EXIST "%CURRENT_DIR%\php5\php.exe" pause
IF NOT EXIST "%CURRENT_DIR%\php5\php.exe" exit

set apache_port=
set /p apache_port=请输入Apache服务器端口(8080)：
if "%apache_port%"=="" set apache_port=8080

set mysql_port=
set /p mysql_port=请输入MySQL服务器端口(6033)：
if "%mysql_port%"=="" set mysql_port=6033

"%CURRENT_DIR%\php5\php.exe" -n "%CURRENT_DIR%\setup.php" %apache_port% %mysql_port%
IF EXIST "%CURRENT_DIR%\install.err" type "%CURRENT_DIR%\install.err"
IF EXIST "%CURRENT_DIR%\install.err" pause
IF EXIST "%CURRENT_DIR%\install.err" exit

"%CURRENT_DIR%\Apache2\bin\Apache.exe" -k install -n Apache2OECSM
net start Apache2OECSM

"%CURRENT_DIR%\MySQL5\bin\mysqld-nt.exe" --install MySQL5OECSM
net start MySQL5OECSM

rem 生成桌面快捷方式
set LINK_FILENAME=登录思迈维修业务通系统.url
set LINK_URL=http://localhost:%apache_port%/
echo [DEFAULT]>>%LINK_FILENAME%
echo BASEURL=%LINK_URL%>>%LINK_FILENAME%
echo [InternetShortcut]>>%LINK_FILENAME%
echo URL=%LINK_URL%>>%LINK_FILENAME%
echo IconIndex=167>>%LINK_FILENAME%
echo IconFile=%windir%\system32\shell32.dll>>%LINK_FILENAME%
IF EXIST "%userprofile%\桌面\%LINK_FILENAME%" del "%userprofile%\桌面\%LINK_FILENAME%" /Q
IF EXIST "%userprofile%\Desktop\%LINK_FILENAME%" del "%userprofile%\Desktop\%LINK_FILENAME%" /Q
rem 英文桌面系统
IF EXIST "%userprofile%\桌面" copy %LINK_FILENAME% "%userprofile%\桌面"
IF EXIST "%userprofile%\Desktop" copy %LINK_FILENAME% "%userprofile%\Desktop"
rem 加入开始菜单
IF EXIST "%ALLUSERSPROFILE%\「开始」菜单\%LINK_FILENAME%" del "%ALLUSERSPROFILE%\「开始」菜单\%LINK_FILENAME%" /Q
IF EXIST "%ALLUSERSPROFILE%\Start Menu\%LINK_FILENAME%" del "%ALLUSERSPROFILE%\Start Menu\%LINK_FILENAME%" /Q
rem 英文系统
IF EXIST "%ALLUSERSPROFILE%\「开始」菜单" copy %LINK_FILENAME% "%ALLUSERSPROFILE%\「开始」菜单"
IF EXIST "%ALLUSERSPROFILE%\Start Menu" copy %LINK_FILENAME% "%ALLUSERSPROFILE%\Start Menu"

rem 加入到开始程序菜单并建立目录 思迈软件
set PROGRAME_DIR="%ALLUSERSPROFILE%\「开始」菜单\程序\思迈软件"
mkdir %PROGRAME_DIR%

copy %LINK_FILENAME% %PROGRAME_DIR%
copy 来电显示.bat %PROGRAME_DIR%
copy 启动服务.bat %PROGRAME_DIR%
copy 安装来电驱动.bat %PROGRAME_DIR%
copy 停止服务.bat %PROGRAME_DIR%
copy 数据备份.bat %PROGRAME_DIR%
copy 安装帮助.txt %PROGRAME_DIR%

echo 系统环境配置成功，下一步将进行系统初始化。
pause

rem 打开浏览器,安静模式安装
"%ProgramFiles%\Internet Explorer\IEXPLORE.EXE" http://localhost:%apache_port%/system/install.php?p=q,%mysql_port%