折腾了整整一天,终于将 MSDE 2000 SP4  和 N 年前用 VB6 开发的一个系统完整的打包到一张光盘上。想当初,VB6 用提供那个安装部署向导制作的安装包需要用户把系统要用到 N 个程序安装 N  遍……甚至 N + X  遍 !且不说用户抱怨,我也不省其繁。
1、从  http://www.microsoft.com/downloads/details.aspx?familyid=8E2DFC8D-C20E-4446-99A9-B7F0213F8BC5&displaylang=zh-cn 下载 MSDE 2000 SP4,打包备用;
2、在 Installshield 12 Premier  创建一个 InstallScript  项目。要创建这种项目需要现安装 Installshield Installscript Objects,这个部件可以从 http://www.installshield.com 下载;
选择 InstallScript  项目的原因是我们要利用 InstallScript 脚本代码来完成 MSDE 2000 SP4  的安装。设置 InstallScript  项目具体过程没什么别需要说明的,整个过程很比较简单。唯一要注意的是在“Build Installation”这一步骤是选择“CD-ROM”以便于随后我们向这个安装影像中添加 MSDE 2000 SP4 的安装目录;
3、编写 InstallScript 代码。在 Installation Designer 卡片中,单击左边那棵树中的“InstallScript” 结点。在右边的 Setup.Rul 窗格中顶部第一个DropDownList 中选中“After Move Data” ,在第二个DropDownList 中选中“OnFirstUIAfter”,系统自动添加 OnFirstUIAfter() 函数。对各位大侠来说,这些代码简直是小菜一碟。
 //---------------------------------------------------------------------------
//--------------------------------------------------------------------------- // OnFirstUIAfter
// OnFirstUIAfter //
// // First Install UI Sequence - After Move Data
// First Install UI Sequence - After Move Data //
// // The OnFirstUIAfter event called by OnShowUI after the file transfer
// The OnFirstUIAfter event called by OnShowUI after the file transfer // of the setup when the setup is running in first install mode. By default
// of the setup when the setup is running in first install mode. By default // this event displays UI that informs the end user that the setup has been
// this event displays UI that informs the end user that the setup has been // completed successfully.
// completed successfully. //
// // Note: This event will not be called automatically in a
// Note: This event will not be called automatically in a // program
// program endprogram style setup.
endprogram style setup. //---------------------------------------------------------------------------
//--------------------------------------------------------------------------- function OnFirstUIAfter()
function OnFirstUIAfter() STRING szTitle, szMsg1, szMsg2, szOpt1, szOpt2;
    STRING szTitle, szMsg1, szMsg2, szOpt1, szOpt2; NUMBER bvOpt1, bvOpt2;
    NUMBER bvOpt1, bvOpt2; NUMBER bShowUpdateServiceDlg;
    NUMBER bShowUpdateServiceDlg; STRING szWaitText;
    STRING szWaitText; STRING szServiceName;
    STRING szServiceName; NUMBER svServiceState;
    NUMBER svServiceState; STRING szMsde2000, szCmdLine,szStartServiceArgs;
    STRING szMsde2000, szCmdLine,szStartServiceArgs; begin
begin // 如果安装程序以“维护”模式启动
    // 如果安装程序以“维护”模式启动 if (MAINTENANCE) then
    if (MAINTENANCE) then goto EndProcess;
        goto EndProcess; endif;
    endif;
 // 检查系统是否安装了 MSDE 2000 SP4
    // 检查系统是否安装了 MSDE 2000 SP4 szWaitText = "正在检查系统是否安装了 MSDE2000 SP4 …….";
    szWaitText = "正在检查系统是否安装了 MSDE2000 SP4 ……."; SdShowMsg( szWaitText, TRUE);
    SdShowMsg( szWaitText, TRUE);     
     szServiceName = "MSSQLSERVER";
    szServiceName = "MSSQLSERVER"; if(ServiceGetServiceState(szServiceName, svServiceState) < ISERR_SUCCESS) then
    if(ServiceGetServiceState(szServiceName, svServiceState) < ISERR_SUCCESS) then // 没有安装 MSDE,转安装处理
        // 没有安装 MSDE,转安装处理 goto InstallMSDE;
        goto InstallMSDE;     endif;
    endif; goto StartMSDE;
    goto StartMSDE;  
     InstallMSDE:  // 安装数据库服务
InstallMSDE:  // 安装数据库服务   szWaitText = "正在安装 MSDE2000 SP4。这个过程需要几分钟,请稍等
    szWaitText = "正在安装 MSDE2000 SP4。这个过程需要几分钟,请稍等 ";
"; SdShowMsg(szWaitText, TRUE);
    SdShowMsg(szWaitText, TRUE);  
     szMsde2000 = SRCDIR ^ "MSDE" ^ "setup.exe";
    szMsde2000 = SRCDIR ^ "MSDE" ^ "setup.exe"; // 将 MSDE 2000 SP4 安装到系统 Program File 目录下
    // 将 MSDE 2000 SP4 安装到系统 Program File 目录下 szCmdLine = "TARGETDIR=\"" + PROGRAMFILES + "\" /q";
    szCmdLine = "TARGETDIR=\"" + PROGRAMFILES + "\" /q"; if(LaunchAppAndWait(szMsde2000, szCmdLine, LAAW_OPTION_WAIT|LAAW_OPTION_MAXIMIZED) < 0 ) then
    if(LaunchAppAndWait(szMsde2000, szCmdLine, LAAW_OPTION_WAIT|LAAW_OPTION_MAXIMIZED) < 0 ) then MessageBox ("安装 MSDE2000 SP4 失败,请联系系统管理员!", SEVERE);
        MessageBox ("安装 MSDE2000 SP4 失败,请联系系统管理员!", SEVERE); goto EndProcess;
        goto EndProcess; endif;
    endif;
 StartMSDE: // 启动 MSDE2000 服务
StartMSDE: // 启动 MSDE2000 服务 szWaitText = "正在启动 MSDE2000 SP4 …….";
    szWaitText = "正在启动 MSDE2000 SP4 ……."; SdShowMsg( szWaitText, TRUE);
    SdShowMsg( szWaitText, TRUE);     
    // 安装了 MSDE 2000, 试着启动服务
    // 安装了 MSDE 2000, 试着启动服务 szStartServiceArgs = "";
    szStartServiceArgs = "";     if(svServiceState != SERVICE_RUNNING) then
    if(svServiceState != SERVICE_RUNNING) then if (ServiceStartService (szServiceName, szStartServiceArgs) < ISERR_SUCCESS ) then
        if (ServiceStartService (szServiceName, szStartServiceArgs) < ISERR_SUCCESS ) then MessageBox ("启动服务" + szServiceName + "出错。", SEVERE);
            MessageBox ("启动服务" + szServiceName + "出错。", SEVERE); goto EndProcess;
            goto EndProcess; endif;
        endif;         endif;
    endif;
 // 加载用户数据库
    // 加载用户数据库 szWaitText = "正在创建所需数据库
    szWaitText = "正在创建所需数据库 .";
."; SdShowMsg(szWaitText, TRUE);
    SdShowMsg(szWaitText, TRUE); Delay(2);
    Delay(2);  
     // 先试着分离先前已经加载的数据库
    // 先试着分离先前已经加载的数据库 szCmdLine = "-E -Q \"exec exec sp_detach_db TestDB \"";
    szCmdLine = "-E -Q \"exec exec sp_detach_db TestDB \""; if(LaunchAppAndWait("osql.exe ", szCmdLine, LAAW_OPTION_WAIT|LAAW_OPTION_HIDDEN) < 0) then
    if(LaunchAppAndWait("osql.exe ", szCmdLine, LAAW_OPTION_WAIT|LAAW_OPTION_HIDDEN) < 0) then  MessageBox ("分离原来的数据库失败!请确认系统中已安装 MSDE 2000 SP4 并且服务已启动。\n如问题仍无法解决,请与联系统管理员联系!", SEVERE);
        MessageBox ("分离原来的数据库失败!请确认系统中已安装 MSDE 2000 SP4 并且服务已启动。\n如问题仍无法解决,请与联系统管理员联系!", SEVERE);  endif;
    endif;  
     // 将数据文件复制到程序安装目录
    // 将数据文件复制到程序安装目录 CreateDir( TARGETDIR ^ "Data");
    CreateDir( TARGETDIR ^ "Data"); CopyFile( SRCDIR ^ "Data" ^ "TestDB.mdf", TARGETDIR ^ "Data" ^ "TestDB.mdf");
    CopyFile( SRCDIR ^ "Data" ^ "TestDB.mdf", TARGETDIR ^ "Data" ^ "TestDB.mdf"); CopyFile( SRCDIR ^ "Data" ^ "TestDB.ldf", TARGETDIR ^ "Data" ^ "TestDB.ldf");
    CopyFile( SRCDIR ^ "Data" ^ "TestDB.ldf", TARGETDIR ^ "Data" ^ "TestDB.ldf");     
     // 附加数据库
    // 附加数据库     szCmdLine = "-E -Q \"exec sp_attach_db 'TestDB', '"+  TARGETDIR ^ "Data" ^ "TestDB.mdf', '" +  TARGETDIR ^ "Data" ^ "TestDB.ldf' \"";
    szCmdLine = "-E -Q \"exec sp_attach_db 'TestDB', '"+  TARGETDIR ^ "Data" ^ "TestDB.mdf', '" +  TARGETDIR ^ "Data" ^ "TestDB.ldf' \"";  if (LaunchAppAndWait("osql.exe ", szCmdLine, LAAW_OPTION_WAIT|LAAW_OPTION_HIDDEN) < 0) then
    if (LaunchAppAndWait("osql.exe ", szCmdLine, LAAW_OPTION_WAIT|LAAW_OPTION_HIDDEN) < 0) then  MessageBox ("数据库创建失败!请确认系统中已安装 MSDE 2000 SP4 并且服务已启动。\n如问题仍无法解决,请与联系统管理员联系!", SEVERE);
          MessageBox ("数据库创建失败!请确认系统中已安装 MSDE 2000 SP4 并且服务已启动。\n如问题仍无法解决,请与联系统管理员联系!", SEVERE);  endif;
    endif; 
     SdShowMsg(szWaitText, FALSE);
    SdShowMsg(szWaitText, FALSE);      
     EndProcess:
EndProcess:     
     // 以下代码是系统自动插入的
    // 以下代码是系统自动插入的 ShowObjWizardPages(NEXT);
    ShowObjWizardPages(NEXT); 
     szTitle = "";
    szTitle = ""; szMsg1 = "";
    szMsg1 = "";  szMsg2 = "";
    szMsg2 = ""; szOpt1 = "";
    szOpt1 = ""; szOpt2 = "";
    szOpt2 = ""; bvOpt1   = FALSE;
    bvOpt1   = FALSE; bvOpt2   = FALSE;
    bvOpt2   = FALSE;    
 // Set this to true if you have the update service enabled, and if you want to check for updates.
    // 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,
    // 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.
    // only set this to true if you have at least the ISUS Professional Edition. bShowUpdateServiceDlg = FALSE;
    bShowUpdateServiceDlg = FALSE; 
     //{{IS_SCRIPT_TAG(Dlg_SdDinishEx)
    //{{IS_SCRIPT_TAG(Dlg_SdDinishEx)     
     if ( BATCH_INSTALL ) then
    if ( BATCH_INSTALL ) then SdFinishReboot ( szTitle , szMsg1 , SYS_BOOTMACHINE , szMsg2 , 0 );
        SdFinishReboot ( szTitle , szMsg1 , SYS_BOOTMACHINE , szMsg2 , 0 ); else
    else 
         // If the update service is enabled, show finish dialog that includes
        // If the update service is enabled, show finish dialog that includes // update check option.
        // update check option. if( bShowUpdateServiceDlg && ( ENABLED_ISERVICES & SERVICE_ISUPDATE ) ) then
        if( bShowUpdateServiceDlg && ( ENABLED_ISERVICES & SERVICE_ISUPDATE ) ) then
 if( SdFinishUpdateEx( szTitle, szMsg1, szMsg2, szOpt1, szOpt2, TRUE ) ) then
            if( SdFinishUpdateEx( szTitle, szMsg1, szMsg2, szOpt1, szOpt2, TRUE ) ) then
 // Don't check for updates in silent mode.
                // Don't check for updates in silent mode. if( MODE != SILENTMODE ) then
                if( MODE != SILENTMODE ) then UpdateServiceCheckForUpdates( "", FALSE );
                    UpdateServiceCheckForUpdates( "", FALSE ); endif;
                endif;
 endif;
            endif;
 else
        else SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 );
            SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 ); endif;
        endif;
 endif;
    endif; //}}IS_SCRIPT_TAG(Dlg_SdDinishEx)
    //}}IS_SCRIPT_TAG(Dlg_SdDinishEx)     end;
end; 4、按F7 制作安装影像。生成的安装影像文件位于 [盘符:]\InstallShield Express Projects\[安装项目名称]\Media\cdrom\Disk Images\Disk1
5、向影像中添加 MSDE 2000 SP4 的安装文件。
5a)请先参照 MSDE 2000 ReadmeSql2k32desksp4.htm 中《4.1 再分发 MSDE 2000 SP4》的说明。
5b)打开文件夹 [盘符:]\InstallShield Express Projects\[安装项目名称]\Media\cdrom\Disk Images\Disk1, 然后创建两个子文件 MSDE 和 Data 。
[盘符:]\InstallShield Express Projects\[安装项目名称]\Media\cdrom\Disk Images\Disk1\MSDE 用于存放 MSDE 2000 SP4 安装文件;
[盘符:]\InstallShield Express Projects\[安装项目名称]\Media\cdrom\Disk Images\Disk1\Data 用于存放你要安装的数据库文件;
6、说明:MSDE 2000 ReadmeSql2k32desksp4.htm 中《4.1 再分发 MSDE 2000 SP4》中的说明并太确切。实际上,为了让 MSDE 2000 SP4 的Setup.exe 正确运行,还需要将所下载并解压 MSDE 2000 SP4 中 *.dll 和 *.rll 复制到 [盘符:]\InstallShield Express Projects\[安装项目名称]\Media\cdrom\Disk Images\Disk1\MSDE 中
 
                     
                    
                 
                    
                 
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号