最近为了打包程序被Installshield折腾死了,记个备忘。
AE打包:
function OnMoved() string szCommand,szCmdLine,szPath,svResult,LicPath,tempdir; STRING svLine,svReturnLine,InsertTxt; //////操作文件的变量 NUMBER nvFileHandle; //////////文件句柄 NUMBER nvLineNumber ,nvResult; //////////操作文件的变量 begin szPath=SUPPORTDIR^"arcengine"; szCommand = WINSYSDIR^"msiexec.exe"; LongPathToShortPath(szCommand); //安装dotnetfx2.exe //GetEnvVar("TEMP", tempdir);//得到临时目录 //FindAllFiles(SUPPORTDIR^"dotnetfx", "install.exe" , tempdir, CONTINUE );//在临时目录下搜索dotnetfx.exe文件 SdShowMsg("正在安装.NET 2.0,请稍后...", TRUE); if(LaunchAppAndWait(SUPPORTDIR^"dotnetfx"^"install.exe", "/q /norestart",WAIT)<0) then SdShowMsg("安装.NET 2.0失败", TRUE); abort; SdShowMsg("安装.NET 2.0失败", FALSE); endif; SdShowMsg("正在安装.NET 2.0,请稍后...", FALSE); ////////////////////////安装AE 运行时 if (FindFile (szPath, "setup.msi", svResult) = 0) then szCmdLine = SUPPORTDIR^"arcengine"^"setup.msi\"/qn"; LongPathToShortPath(szCmdLine); SdShowMsg("正在安装ArcGIS Engine Runtime,依据机器性能需要几分钟到十几分钟,请稍后...", TRUE); Delay(1); if (LaunchAppAndWait(szCommand ,"/i \""+szCmdLine,WAIT) < 0) then MessageBox("安装ArcGIS Engine Runtime失败!", WARNING); abort; SdShowMsg("正在安装ArcGIS Engine Runtime,依据机器性能需要几分钟到十几分钟,请稍后...", FALSE); endif; endif; /////////////////////////AE 授权 LicPath=" -Lif \"" +SUPPORTDIR^"arcengine\\ecp\\license9-30.ecp\" -s"; SdShowMsg("正在对ArcGIS Engine Runtime授权,请稍后...", TRUE); if (FindFile (SUPPORTDIR^"arcengine"^"ecp", "license9-30.ecp", svResult) = 0) then if(SYSINFO.bIsWow64) then szCmdLine="C:\\Program Files(x86)\\ArcGIS\\Bin\\SoftwareAuthorization.exe"; else szCmdLine="C:\\Program Files\\ArcGIS\\Bin\\SoftwareAuthorization.exe "; endif; if (LaunchAppAndWait(szCmdLine ,LicPath,WAIT) < 0) then MessageBox("授权错误!",WARNING); //abort; endif; endif; if (ExistsDir(TARGETDIR^"temp")=0 ) then if (DeleteProgramFolder (TARGETDIR^"temp") < 0) then endif ; endif ; SdShowMsg("正在对ArcGIS Engine Runtime授权,请稍后...", FALSE); end;
SQL SERVER打包:
function OnFirstUIAfter() STRING szTitle, szMsg1, szMsg2, szOpt1, szOpt2; NUMBER bvOpt1, bvOpt2; NUMBER bShowUpdateServiceDlg; STRING szWaitText; STRING szServiceName; NUMBER svServiceState; STRING szMsde2005, szCmdLine,szStartServiceArgs, szSSMSEE, szCommand, appPath; begin // 如果安装程序以“维护”模式启动 if (MAINTENANCE) then goto EndProcess; endif; // 检查系统是否安装了 MSDE 2005 szWaitText = "正在检查系统是否安装了 MSSQLSERVER ."; SdShowMsg( szWaitText, TRUE); szServiceName = "MSSQL$SQLEXPRESS"; if(ServiceGetServiceState(szServiceName, svServiceState) < ISERR_SUCCESS) then // 没有安装 MSSQLSERVER,转安装处理 goto InstallMSDE; endif; goto StartMSDE; InstallMSDE: // 安装数据库服务 szWaitText = "正在安装 MSSQLSERVER 2005。这个过程需要几分钟,请稍等"; SdShowMsg(szWaitText, TRUE); szMsde2005 = SUPPORTDIR^"SQLEXPR.exe"; //LongPathToShortPath(szMsde2005); //szSSMSEE = SUPPORTDIR ^ "SQLServer2005_SSMSEE.exe /qn"; szCommand = WINSYSDIR^"msiexec.exe"; //szCmdLine = "/x:" + SUPPORTDIR^"sqlexpr"; ////解压 SQLEXPR.exe //if(LaunchAppAndWait(SUPPORTDIR^"SQLEXPR.exe", szCmdLine, LAAW_OPTION_WAIT|LAAW_OPTION_MAXIMIZED) < 0 ) then // 将 MSDE 2005 安装到系统 Program File 目录下 szCmdLine = "TARGETDIR=\"" + PROGRAMFILES + "\" /qb /norebootchk SECURITYMODE=SQL SAPWD=123 ADDLOCAL=ALL DISABLENETWORKPROTOCOLS=0 SQLAUTOSTART=1"; if(LaunchAppAndWait(szMsde2005, szCmdLine, LAAW_OPTION_WAIT|LAAW_OPTION_MAXIMIZED) < 0 ) then MessageBox ("安装 MSSQLSERVER 2005 失败,请联系系统管理员!", SEVERE); goto EndProcess; endif; //endif; //if (LaunchAppAndWait(szCommand ,"/i \""+szSSMSEE,WAIT) < 0) then // MessageBox("安装MSDE2005 Studio失败!", WARNING); // abort; //endif; StartMSDE: // 启动 MSSQLSERVER 服务 //设置端口号 REGDB_OPTIONS = REGDB_OPTIONS & ~REGDB_OPTION_WOW64_64KEY; //disable 64 REGDB_OPTIONS | REGDB_OPTION_WOW64_64KEY //enable 64 REGDB_OPTIONS & ~REGDB_OPTION_WOW64_64KEY RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); RegDBSetKeyValueEx("SOFTWARE\\Microsoft\\Microsoft SQL Server\\MSSQL.1\\MSSQLServer\\SuperSocketNetLib\\Tcp\\IPAll", "TcpPort", REGDB_STRING, "1433", -1); //MessageBox ("修改 MSSQLSERVER 2005 端口失败,请联系系统管理员!", SEVERE); //endif; Delay(2); ServiceStopService (szServiceName); Delay(2); szWaitText = "正在启动 MSSQLSERVER ."; SdShowMsg( szWaitText, TRUE); // 安装了 MSDE 2005, 试着启动服务 szStartServiceArgs = ""; //if(svServiceState != SERVICE_RUNNING) then if (ServiceStartService (szServiceName, szStartServiceArgs) < ISERR_SUCCESS ) then MessageBox ("启动服务" + szServiceName + "出错。", SEVERE); goto EndProcess; endif; //endif; // 加载用户数据库 szWaitText = "正在创建所需数据库."; SdShowMsg(szWaitText, TRUE); Delay(2); // 先试着分离先前已经加载的数据库 szCmdLine = "/E /Q \"exec sp_detach_db 'xxxxx'\""; //LAAW_OPTION_NOWAIT | LAAW_OPTION_HIDDEN if(LaunchAppAndWait("osql.exe ", szCmdLine, WAIT) < 0) then // MessageBox ("分离原来的数据库失败!请确认系统中已安装 MSSQLSERVER 并且服务已启动。如问题仍无法解决,请与联系统管理员联系!", SEVERE); endif; Delay(2); // 将数据文件复制到程序安装目录 //CreateDir( TARGETDIR ^ "Database"); //CopyFile( SRCDIR ^ "Database" ^ "xxxxx.mdf", TARGETDIR ^ "Database" ^ "xxxxx.mdf"); //CopyFile( SRCDIR ^ "Database" ^ "xxxxx_log.ldf", TARGETDIR ^ "Database" ^ "xxxxx_log.ldf"); // 附加数据库 appPath = PROGRAMFILES^"xxxxx"^"xxxxx"^"database"; LongPathToShortPath(appPath); WriteLog("apPath:"+appPath); //szCmdLine = "/E /Q \"exec sp_attach_db @dbname=N'xxxxx','"+ PROGRAMFILES^"信息系统"^"database"^"xxxxx.mdf','" + PROGRAMFILES"^"信息系统"^"database"^"xxxxx_log.ldf'\""; szCmdLine = "/E /Q \"exec sp_attach_db 'xxxxx', '" + appPath + "\\xxxxx.mdf', '" + appPath + "\\xxxxx_log.ldf'\" "; WriteLog("szCmdLine:"+szCmdLine); //LAAW_OPTION_NOWAIT | LAAW_OPTION_HIDDEN if (LaunchAppAndWait("osql.exe", szCmdLine, WAIT) < 0) then MessageBox ("数据库创建失败!请确认系统中已安装 MSSQLSERVER 并且服务已启动。如问题仍无法解决,请与联系统管理员联系!", SEVERE); endif; SdShowMsg(szWaitText, FALSE); EndProcess: //owh add SdShowMsg(szWaitText, FALSE); // 以下代码是系统自动插入的 ShowObjWizardPages(NEXT); szTitle = ""; szMsg1 = ""; szMsg2 = ""; szOpt1 = ""; szOpt2 = ""; bvOpt1 = FALSE; bvOpt2 = FALSE; // Set this to true if you have the update service enabled, and if you want to check for updates. // Note: the ISUS Starter Edition does not support checking for updates programatically. So, // only set this to true if you have at least the ISUS Professional Edition. bShowUpdateServiceDlg = FALSE; //{{IS_SCRIPT_TAG(Dlg_SdDinishEx) if ( BATCH_INSTALL ) then SdFinishReboot ( szTitle , szMsg1 , SYS_BOOTMACHINE , szMsg2 , 0 ); else // If the update service is enabled, show finish dialog that includes // update check option. if( bShowUpdateServiceDlg && ( ENABLED_ISERVICES & SERVICE_ISUPDATE ) ) then if( SdFinishUpdateEx( szTitle, szMsg1, szMsg2, szOpt1, szOpt2, TRUE ) ) then // Don't check for updates in silent mode. if( MODE != SILENTMODE ) then UpdateServiceCheckForUpdates( "", FALSE ); endif; endif; else SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 ); endif; endif; //}}IS_SCRIPT_TAG(Dlg_SdDinishEx) //owh add abort; end;