cd ftoneSetup
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{257F3903-2A88-4C4B-AFE7-EE8923C5C99B}
if errorlevel 1 goto inst
msiexec /passive /x{257F3903-2A88-4C4B-AFE7-EE8923C5C99B}
:inst
setup
if errorlevel 1 goto endf
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{90120000-00D1-0804-0000-0000000FF1CE}
if errorlevel 1 AccessDatabaseEngine

cd ..\sqlserver
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{B5153233-9AEE-4CD4-9D2C-4FAAC870DBE2} /v instanceId
if errorlevel 1 goto instdb
goto overdb
:instdb
SQLEXPR_x86_CHS /action=Install /features=SQL /instancename=SQLEXPRESS /enableranu=1 /sqlsvcaccount="NT Authority\Network Service" /AddCurrentUserAsSqlAdmin /skiprules=RebootRequiredCheck

if errorlevel 1 goto endf

:overdb
path %ProgramFiles%\Microsoft SQL Server\100\Tools\Binn;%PATH%
sqlcmd -S.\sqlexpress -E -iftone30.sql
if errorlevel 1 goto endf
echo 安装成功
goto endOK

:endf
pause 安装已中止
