急问,MSDE打包问题??
项目中用到Installsheild2008打包MSDE2000SP4,实现安装过程的MSDE自动安装,数据库加载,用户添加等;但当前在新系统(XP)中第一次安装总是失败,卸载后安装或者注销后修复都可以成功,百思不得其解,不知甚么原因,还请达人相助;
主要程序:
//检查是否安装MSDE service;
if(ServiceGetServiceState(szServiceName, svServiceState) < ISERR_SUCCESS) then
goto InstallMSDE;
endif;
goto StartMSDE;
//安装MSDE;
InstallMSDE:
TARGETDIR ^ "Server" ^"MSDE" ^ "setup.exe";
szCmdLine = "TARGETDIR=\"" + PROGRAMFILES + "\" reboot=ReallySuppress /qn /i";
if(LaunchAppAndWait(szMsde2000 , szCmdLine, LAAW_OPTION_WAIT|LAAW_OPTION_MAXIMIZED) < 0 ) then
MessageBox ("install failed",SEVERE);
endif;
szSQLsvr = "(local)" ^ "Example";
//启动MSDE;
StartMSDE:
szStartServiceArgs = "";
if(ServiceGetServiceState(szServiceName,svServiceState)< ISERR_SUCCESS) then
MessageBox ("获取服务" + szServiceName + "出错", SEVERE);
if (ServiceStartService (szServiceName, szStartServiceArgs) < ISERR_SUCCESS ) then
MessageBox ("启动服务" + szServiceName + "³出错", SEVERE);
//abort;
endif;
else
if(svServiceState != SERVICE_RUNNING) then
if (ServiceStartService (szServiceName, szStartServiceArgs) < ISERR_SUCCESS ) then
MessageBox ("启动服务" + szServiceName + "出错", SEVERE);
//abort;
endif;
endif;
endif;
//分离加载数据库及用户;
szSQLsvr = "(local)" ^ "Example";
szCmdLine = "-U \"sa\" -P \"pwd\" -S "+szSQLsvr+" -Q \"exec sp_detach_db 'TestDB' \"";
if(LaunchAppAndWait("osql.exe ", szCmdLine, LAAW_OPTION_WAIT|LAAW_OPTION_HIDDEN) < 0) then
MessageBox ("Detach failed", SEVERE);
endif;
szCmdLine = "-U \"sa\" -P \"pwd\" -S "+szSQLsvr+" -Q \"exec sp_attach_db 'TestDB','"+TARGETDIR^ "Server" ^ "Data" ^ "TestDB_data.mdf', '"+TARGETDIR^ "Server"^"Data"^"TestDB_log.ldf'\"";
if (LaunchAppAndWait("osql.exe ", szCmdLine, LAAW_OPTION_WAIT|LAAW_OPTION_HIDDEN) < 0) then
MessageBox ("Attach failed", SEVERE);
endif;
szCmdLine = "-U \"sa\" -P \"pwd\" -S "+szSQLsvr+" -i \""+TARGETDIR ^ "Server" ^ "MSDE" ^ "TestDBAddUser.sql \"";
if (LaunchAppAndWait("osql.exe ", szCmdLine, LAAW_OPTION_WAIT|LAAW_OPTION_HIDDEN) < 0) then
MessageBox ("Add User failed", SEVERE);
endif;