@ECHO OFF
echo 获取文件路径...
CD>test.txt
ping -n 4 127.1>nul 2>nul
for /f "delims=" %%i in (test.txt) do set i=%%i
echo %i%
echo 环境变量添加中...
wmic ENVIRONMENT where "name='path' and username='<system>'" set VariableValue="%path%;%i%\php"
echo 替换环境配置文件中的安装路径稍等...
set file=php.ini
set "file=%file:"=%"
for %%i in ("%file%") do set file=%%~fi
echo.
set replaced=D:/host
echo.
set all=%i%
cd.>"%file%_tmp.ini"
setlocal enabledelayedexpansion
for /f "tokens=1* delims=:" %%i in ('findstr /n .* "%file%"') do (
    set str=%%j
    if not "!str!"=="" set "str=!str:%replaced%=%all%!"
    >>"%file%_tmp.ini" echo.!str!
)
copy "%file%" "%file%_bak.ini" >nul 2>nul
move "%file%_tmp.ini" "%file%"
ping -n 4 127.1>nul 2>nul
set file=%i%\MySQL545\my.ini
set "file=%file:"=%"
for %%i in ("%file%") do set file=%%~fi
echo.
set replaced=D:/host
echo.
set all=%i%
cd.>"%file%_tmp.ini"
setlocal enabledelayedexpansion
for /f "tokens=1* delims=:" %%i in ('findstr /n .* "%file%"') do (
    set str=%%j
    if not "!str!"=="" set "str=!str:%replaced%=%all%!"
    >>"%file%_tmp.ini" echo.!str!
)
copy "%file%" "%file%_bak.ini" >nul 2>nul
move "%file%_tmp.ini" "%file%"
ping -n 4 127.1>nul 2>nul
echo 安装中稍等...
echo 安装php...
copy php.ini %SystemRoot%
echo 安装mysql...
%i%\MySQL545\bin\mysqld-nt -install
echo 启动mysql...
net start mysql
del php.ini
del php.ini_bak.ini
del %i%\MySQL545\my.ini_bak.ini
echo php环境安装设置 请稍等...
cscript.exe xcacls.vbs "%i%\php\" /r "users" /e
cscript.exe xcacls.vbs "%i%\php\" /r "everyone" /e
cscript.exe xcacls.vbs "%i%\php\" /r "CREATOR OWNER" /e
cscript.exe xcacls.vbs "%i%\php\" /g "Authenticated Users":x /e
cscript.exe xcacls.vbs "%i%\php\temp\" /g "Authenticated Users":w /e
del xcacls.vbs
echo IIS扩展加载中 请稍等...
cscript.exe iisext.vbs /EnFile c:\WINDOWS\system32\inetsrv\asp.dll
echo 允许ISAPI扩展运行 请稍等...
cscript.exe iisext.vbs /EnFile *.dll
cscript.exe iisext.vbs /AddFile %i%\php\php5isapi.dll 1 php 0 php
del iisext.vbs
echo 创建phpmysql管理站点...
cscript.exe iisweb.vbs /create %i%\phpMyAdmin "phpMyAdmin" /b 8080
del iisweb.vbs
start %SystemRoot%\system32\inetsrv\iis.msc
start %i%\dll.JPG
echo 是否已经添加了phpisapi扩展，路径为：%i%\php\php5isapi.dll,务必先添加
echo 请查看图片，添加扩展后在下一步
pause
echo IIS停止并重新启动中...
net stop iisadmin /yes 
net start iisadmin 
net start w3svc
start http://localhost:8080/index.php
echo 打开安装目录...
start %i%\
echo 阅读说明...
start %i%\说明.txt
echo 恭喜你！安装完成，稍等程序自动退出...
del test.txt
@del %0