Search code examples
c#.netinstallshieldinstallscript

how to add two installation types inside single setup file in installscript


I am using InstallShield 2013 for deployment packages and I want to add two installation types(two applications) in single setup file. I mean , the user should be able to select which application is to be installed when running the setup file at the installShield.

Background

In my setup file there are two applications as Console and Viewer. The user can select the application he/she wants but further installation for the selected application does not work. Need help!

Here is my code.

function OnFirstUIBefore()
      NUMBER nResult, nType;   
      STRING szTitle, szMsg, svResult, szCaption;   
      NUMBER nSetupType, nvSize, nUser, nReserved;
      STRING szQuestion, svName, svCompany, szFile, szLicense;
      STRING szLicenseFile,szReserved, svSetupType;
      LIST list, listStartCopy;
      BOOL bCustom, bCopy, bDontCopy;

begin           
      MessageBox("OnFirstUIBefore()",0);
      SHELL_OBJECT_FOLDER = @PRODUCT_NAME;     
      nSetupType = CUSTOM;     
      bCopy = FALSE ; 
      bDontCopy = TRUE ; 
      bCustom = TRUE;      
      szLicense = SUPPORTDIR^ "AbcTerms.rtf";   

Dlg_SdWelcome:
    szTitle = "";
    szMsg   = "";
    nResult = SdWelcome(szTitle, szMsg);
    if (nResult = BACK) goto Dlg_SdWelcome; 
    szTitle   = "";
    svName    = "";
    svCompany = "";   

Dlg_SdLicense:            
   nResult = SdLicense2Rtf ( "","" , "", szLicense , FALSE );    
   if(nResult = BACK) goto  Dlg_SdWelcome;

Dlg_SdCustomerInformation:
    nResult = SdCustomerInformation(szTitle, svName, svCompany, nUser);
    if (nResult = BACK) goto Dlg_SdLicense;

Dlg_SetupType:            
    szTitle = "Please select installation type"; 
    szMsg = ""; 
    szReserved  = ""; 
    svSetupType = "Viewer"; 
    nReserved   = 0;  

    nResult = SdSetupTypeEx(szTitle, szMsg, szReserved, svSetupType, nReserved);
    INSTALLTYPE =  svSetupType;   //"Console";//  
    if(svSetupType == "Console") then  
         MsiSetProperty( ISMSI_HANDLE, "DOCUSTOMEACTION" , 'copy' ); 
         MsiSetProperty( ISMSI_HANDLE, "INSTALLMODE" ,  "ConsoleV3");//"1:3"           
    else
         MsiSetProperty( ISMSI_HANDLE, "INSTALLMODE" , "ViewerV3" );     //"1:2"        
    endif;
    MsiSetProperty( ISMSI_HANDLE, "SOURCEPATH" , SourceDir ); 
    if (nResult = BACK) goto Dlg_SdCustomerInformation; 

Dlg_SdAskDestPath:      
    nResult = SdAskDestPath(szTitle, szMsg, INSTALLDIR, 0);
    if (nResult = BACK) goto Dlg_SetupType;     
Enable(STATUSEX);
    return 0; end;    

Edited Code

function OnFirstUIBefore()
      NUMBER nResult, nType;   
      STRING szTitle, szMsg, svResult, szCaption;   
      NUMBER nSetupType, nvSize, nUser, nReserved;
      STRING szQuestion, svName, svCompany, szFile, szLicense;
      STRING szLicenseFile,szReserved, svSetupType;
      LIST list, listStartCopy;
      BOOL bCustom, bCopy, bDontCopy;

begin           
      MessageBox("OnFirstUIBefore()",0);
      SHELL_OBJECT_FOLDER = @PRODUCT_NAME;     
      nSetupType = CUSTOM;     
      bCopy = FALSE ; 
      bDontCopy = TRUE ; 
      bCustom = TRUE;      
      szLicense = SUPPORTDIR^ "AbcTerms.rtf";   

Dlg_SdWelcome:
    szTitle = "";
    szMsg   = "";
    nResult = SdWelcome(szTitle, szMsg);
    if (nResult = BACK) goto Dlg_SdWelcome; 
    szTitle   = "";
    svName    = "";
    svCompany = "";   

Dlg_SdLicense:            
   nResult = SdLicense2Rtf ( "","" , "", szLicense , FALSE );    
   if(nResult = BACK) goto  Dlg_SdWelcome;

Dlg_SdCustomerInformation:
    nResult = SdCustomerInformation(szTitle, svName, svCompany, nUser);
    if (nResult = BACK) goto Dlg_SdLicense;

Dlg_SetupType:            
    szTitle = "Please select installation type"; 
    szMsg = ""; 
    szReserved  = ""; 
    svSetupType = "Viewer"; 
    nReserved   = 0;  

    nResult = SdSetupTypeEx(szTitle, szMsg, szReserved, svSetupType, nReserved);
    INSTALLTYPE =  svSetupType;   //"Console";// 

    MsiSetProperty( ISMSI_HANDLE, "DOCUSTOMEACTION" , 'copy' );

    if(svSetupType == "Console") then  

         MsiSetProperty( ISMSI_HANDLE, "INSTALLMODE" ,  "ConsoleV3");//"1:3"           
    else
         MsiSetProperty( ISMSI_HANDLE, "INSTALLMODE" , "ViewerV3" );     //"1:2"        
    endif;
    MsiSetProperty( ISMSI_HANDLE, "SOURCEPATH" , SourceDir ); 
    if (nResult = BACK) goto Dlg_SdCustomerInformation; 

Dlg_SdAskDestPath:      
    nResult = SdAskDestPath(szTitle, szMsg, INSTALLDIR, 0);
    if (nResult = BACK) goto Dlg_SetupType;     
Enable(STATUSEX);
    return 0; end;

Solution

  • This works fine.

    function OnFirstUIBefore()
          NUMBER nResult, nType;   
          STRING szTitle, szMsg, svResult, szCaption;   
          NUMBER nSetupType, nvSize, nUser, nReserved;
          STRING szQuestion, svName, svCompany, szFile, szLicense;
          STRING szLicenseFile,szReserved, svSetupType;
          LIST list, listStartCopy;
          BOOL bCustom, bCopy, bDontCopy;
    
    begin           
          MessageBox("OnFirstUIBefore()",0);
          SHELL_OBJECT_FOLDER = @PRODUCT_NAME;     
          nSetupType = CUSTOM;     
          bCopy = FALSE ; 
          bDontCopy = TRUE ; 
          bCustom = TRUE;      
          szLicense = SUPPORTDIR^ "AbcTerms.rtf";   
    
    Dlg_SdWelcome:
        szTitle = "";
        szMsg   = "";
        nResult = SdWelcome(szTitle, szMsg);
        if (nResult = BACK) goto Dlg_SdWelcome; 
        szTitle   = "";
        svName    = "";
        svCompany = "";   
    
    Dlg_SdLicense:            
       nResult = SdLicense2Rtf ( "","" , "", szLicense , FALSE );    
       if(nResult = BACK) goto  Dlg_SdWelcome;
    
    Dlg_SdCustomerInformation:
        nResult = SdCustomerInformation(szTitle, svName, svCompany, nUser);
        if (nResult = BACK) goto Dlg_SdLicense;
    
    Dlg_SetupType:            
        szTitle = "Please select installation type"; 
        szMsg = ""; 
        szReserved  = ""; 
        svSetupType = "Viewer"; 
        nReserved   = 0;  
    
        nResult = SdSetupTypeEx(szTitle, szMsg, szReserved, svSetupType, nReserved);
        INSTALLTYPE =  svSetupType;   //"Console";// 
    
        MsiSetProperty( ISMSI_HANDLE, "DOCUSTOMEACTION" , 'copy' );
    
        if(svSetupType == "Console") then  
    
             MsiSetProperty( ISMSI_HANDLE, "INSTALLMODE" ,  "ConsoleV3");//"1:3"           
        else
             MsiSetProperty( ISMSI_HANDLE, "INSTALLMODE" , "ViewerV3" );     //"1:2"        
        endif;
        MsiSetProperty( ISMSI_HANDLE, "SOURCEPATH" , SourceDir ); 
        if (nResult = BACK) goto Dlg_SdCustomerInformation; 
    
    Dlg_SdAskDestPath:      
        nResult = SdAskDestPath(szTitle, szMsg, INSTALLDIR, 0);
        if (nResult = BACK) goto Dlg_SetupType;     
    Enable(STATUSEX);
        return 0; end;