Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

OnBegin - additional dialogs


5 replies to this topic

Chelley

Chelley
  • Members
  • 43 posts

Posted 19 October 2004 - 16:27

Hi

I'm trying to move my installscript code from being within OnUIBefore and OnUIAfter functions into OnBegin. All seemed to work fine until it got to the final dialog which should be for it to just start the installation. Instead it went to a standard welcome dialog, then a standard custome information, destination and then copy dialogs. It then installs as it should. I tried stepping through the code but for the life of me I cannot see where its suddenly finding these extra dialogs.

Also if I install it like this when I go to Add/Remove programs, the application is listed but when you try to remove it it goes and installs it again and doesn't seem to recognise that its already installed.

I've included my code to show what happens:-


function OnBegin()
NUMBER nResult, nSetupType, nvSize, nUser,nAnswer, nCmdValue;
STRING szTitle, szSubTitle,szMsg, szTemp, szQuestion, svName,szSolutionId ;
STRING szLicenseFile,svCompany, szFile,szDialogName;
STRING szField1,szField2, svEdit1,svEdit2;
STRING svDomainName;
LIST list, listStartCopy;
LIST listLogonNames,listSolutionNames;
BOOL bCustom, bDone;
STRING filename, commandflag;
HWND hNext, hwndDlg;
STRING svResult;
STRING FilePath;
STRING sTarget, sSource, strDir;
STRING svSection ;
NUMBER nvCommDialog, svSolutionId ;
STRING svCustomerId, svVal;
NUMBER szCustomerId, szName, szEdit1, szEdit2;


begin
// TO DO: if you want to enable background, window title, and caption bar title
SetTitle( @PRODUCT_NAME, 24, WHITE );
SetTitle( @PRODUCT_NAME, 0, BACKGROUNDCAPTION );
// Enable( FULLWINDOWMODE );
// Enable( BACKGROUND );
// SetColor(BACKGROUND,RGB (0, 128, 128));

SHELL_OBJECT_FOLDER = @PRODUCT_NAME;

nSetupType = TYPICAL;
OASISUSER ="";
COMPANYNAME="";
USERNAME = "";
SOLUTIONID = "";

Dlg_InstallWelcome:
szTitle = "";
szMsg = "";
// Display the dialog and return the next dialog event.
nResult = SdWelcome(szTitle, szMsg);

Dlg_SdLicence:
// Set up the variables to pass as parameters to SdLicense.

szTitle = "";
szMsg = "";
szQuestion = "";
szLicenseFile = SUPPORTDIR ^ "EULA.txt";
Enable(BACKBUTTON);
// Display the SdLicense dialog box.
nResult =SdLicense (szTitle, szMsg, szQuestion, szLicenseFile);

if (nResult = BACK) goto Dlg_InstallWelcome;

Dlg_SdSolutionIdDlg:

svName = "";
szTitle = "Solution Information";
szMsg = "";
listSolutionNames = ListCreate( STRINGLIST );
// If an error occurred, report it; then terminate.
if (listSolutionNames = LIST_NULL) then
MessageBox ("Unable to create list.", SEVERE);
abort;
endif;

if (ListAddString (listSolutionNames, "OASIS", AFTER) < 0) then
MessageBox ("ListAddString failed.", INFORMATION);
endif;
if (ListAddString (listSolutionNames, "UDA", AFTER) < 0) then
MessageBox ("ListAddString failed.", INFORMATION);
endif;
if (ListAddString (listSolutionNames, "CXP", AFTER) < 0) then
MessageBox ("ListAddString failed.", INFORMATION);
endif;

nResult = CdDropDownSelect1) szTitle,szMsg,listSolutionNames,szSolutionId);
ListDestroy(listSolutionNames);

if (nResult = BACK) goto Dlg_SdLicence;

SOLUTIONID = szSolutionId;
SOLUTION_VALUE = SOLUTIONID;
// Convert all characters to upper case.
StrToUpper (SOLUTIONID, szSolutionId);

//Only need to change flow if SolutionID is CXP, UOA or LOGON
if (StrCompare (SOLUTIONID, "CXP")==0) then
AmendFeaturesForCustomer(SOLUTIONID,svName);
goto Dlg_CdSpecifyProfileDB;
endif;



Dlg_SdCustomerInformation:

svName = GlobalCustomer;
svCompany = "";

nResult = CdCustomerInformation(svName,svCompany);
if (nResult = BACK) goto Dlg_SdSolutionIdDlg;
if (nResult != YES) then
return 0;
endif;
USERNAME = svName;


//If the solution is OASIS then it also needs to get Profile DB
//Information first. All other solutions do not need to do this
//and so can go on directly to the next step.
//Also certain features need to be made available to OASIS that
//would not normally be available to other solutions.
if (StrCompare (SOLUTIONID, "OASIS")==0) then
AmendFeaturesForCustomer(SOLUTIONID, svName);
goto Dlg_CdSpecifyProfileDB;
else
AmendFeaturesForCustomer(SOLUTIONID, svName);
endif;
// Convert all characters to upper case.
StrToUpper (USERNAME, svName);

if ( svName = "LSSI") goto Dlg_SdAskDestPath;
if ( svName = "SNT") goto Dlg_SdAskDestPath;
if ( svName = "CW") goto Dlg_SdAskDestPath;
if ( svName = "DEMO") goto Dlg_SdAskDestPath;
if ( svName = "KC") goto Dlg_SdAskDestPath;
if ( svName = "DT") goto Dlg_SdAskDestPath;


Dlg_CdSpecifyProfileDB:


// Set up parameters for call to SdShowDlgEdit2.
szTitle = "Database Information";
szMsg = "Please specify the name of the Server and the Profile Database name.";
szField1 = "Server Name";
szField2 = "Database";
svEdit1 = GlobalServer;
svEdit2 = GlobalDatabase;

// Get source and target folder names.

nResult = CdServerDBDlg (szTitle, szMsg, szField1, szField2,
svEdit1, svEdit2);

if (nResult = BACK) then
if (StrCompare (SOLUTIONID, "OASIS")==0) then
goto Dlg_SdCustomerInformation;
else
goto Dlg_SdSolutionIdDlg;
endif;
endif;
if (nResult < 0) then
return 0;
endif;


StrToUpper (PROFILE_SERVER,svEdit1);
StrToUpper (PROFILE_DB,svEdit2);



Dlg_CdSpecifyProfileDBUser:


// Set up parameters for call to SdShowDlgEdit2.
szTitle = "Database Information";
szMsg = "Please specify the username and password for Profile Database [" + PROFILE_DB +"].";

svEdit1 = GlobalUser;
svEdit2 = "";

// Get uname and pwd
nResult = CdUnamePwd (szTitle, szMsg, svEdit1, svEdit2);
if (nResult = BACK) goto Dlg_CdSpecifyProfileDB;
if (nResult < 0) then
return 0;
endif;

// Convert all characters to upper case.
StrToUpper (szTemp,svEdit1);
PROFILE_UNAME = szTemp;
PROFILE_PWD = svEdit2;


if(DoesDatabaseExist(PROFILE_SERVER, PROFILE_DB, "SQL Server", PROFILE_UNAME, PROFILE_PWD) = FALSE) then
goto Dlg_CdSpecifyProfileDBUser;
endif;

listLogonNames = ListCreate( STRINGLIST );
if(GetVDELogonIDs(PROFILE_SERVER, PROFILE_DB, "SQL Server", PROFILE_UNAME, PROFILE_PWD,listLogonNames) = FALSE) then
goto Dlg_CdSpecifyProfileDBUser;
endif;

if(GetNTDomain(PROFILE_SERVER, PROFILE_DB, "SQL Server", PROFILE_UNAME, PROFILE_PWD, svDomainName) = FALSE) then
return 0;
endif;



Dlg_SdAskDestPath:
szTitle = "";
szMsg = "";
nResult = SdAskDestPath(szTitle, szMsg, INSTALLDIR, 0);
if (nResult = BACK) goto Dlg_CdSpecifyProfileDBUser;


Dlg_SdStartCopy:
szTitle = "";
szMsg = "";
listStartCopy = ListCreate( STRINGLIST );
szTemp = "User Name: " + USERNAME;
ListAddString(listStartCopy,szTemp,AFTER);
if( PROFILE_SERVER != "") then
szTemp = "Server Name: " + PROFILE_SERVER;
ListAddString(listStartCopy,szTemp,AFTER);
endif;
if( PROFILE_DB != "") then
szTemp = "Database Name: " + PROFILE_DB;
ListAddString(listStartCopy,szTemp,AFTER);
endif;
if( PROFILE_UNAME != "") then
szTemp = "Database Logon: " + PROFILE_UNAME;
ListAddString(listStartCopy,szTemp,AFTER);
endif;
if( OASISUSER != "") then
szTemp = "OASIS Logon: " + OASISUSER;
ListAddString(listStartCopy,szTemp,AFTER);
endif;


szTemp = "Installation Directory: " + INSTALLDIR;
ListAddString(listStartCopy,szTemp,AFTER);


nResult = SdStartCopy( szTitle, szMsg, listStartCopy );
ListDestroy(listStartCopy);

if (nResult = BACK) then
if (!bCustom) then
goto Dlg_SdAskDestPath;
else
goto Dlg_SdStartCopy;
endif;
endif;

// Checks what operating system is being run before attempting to install
if SYSINFO.WIN9X.bWin9X = TRUE then
MessageBox("Unable to install on Win9x machine",SEVERE);
return(-1) ;
endif;
if SYSINFO.WIN9X.bWinMe = TRUE then
MessageBox("Unable to install on Win ME machine",SEVERE);
return(-1) ;
else
if SYSINFO.WINNT.bAdmin_Logged_On = TRUE then
//OASISNTLogon.exe installation requires special installation
//prior to anything else being installed as it changes
//the registry to stop any unauthorised user access
if (StrCompare (SOLUTIONID, "OASIS")==0) then
sTarget = WINSYSDIR ;
sSource = SUPPORTDIR + "\\OASISNTLogon.exe";
nResult = XCopyFile(sSource, sTarget, COMP_NORMAL);
if (nResult = 0) then
sTarget = sTarget + "\OASISNTLogon.exe";
if (LaunchAppAndWait (sTarget," /Install",NOWAIT)<0)then;
MessageBox("Unable to copy " + sTarget, INFORMATION);
return(-1) ;
endif;
endif;
endif;
else
MessageBox("Installer does not have administrative rights. Installation cannot continue", WARNING);
return(-1);
endif;
endif;

// setup default status
Enable(STATUSEX);

//HERE IT NOWS GOES THROUGH THE OTHER SEQUENCE OF DIALOGS


return 0;
end;



Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 21 October 2004 - 11:15

Dialogs should usually be in the UI events (OnFirstUIBefore etc). It may not be a good idea to move the to OnBegin. Your dialogs will always be displayed: on first time install, update, repair, uninstall.

That said: did you delete the OnFirstUOBefore function from your script? In this case the default script for this event handler will be executed (which displays these dialogs). To avoid this add the OnFirstUIBefore function to your script, remove all content except the return statement. Same for the other UI handler functions.



Chelley

Chelley
  • Members
  • 43 posts

Posted 21 October 2004 - 14:18

I did this and it solved the problem. However, I'm still not getting all the script being processed. Anything that is now in the OnBegin is being processed but it it then calls another function in another .rul file its not executed.

And as you say on add/remove it still displays the dialogs. I'm guessing there is no way around that.

Sorry for so many questions but i'm trying to avoid having to redo 6 months work by reverting it to a Basic MSI project.

Many thanks

Michelle

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 22 October 2004 - 13:17

I would leave the dialog in OnFirstUIBefore etc.
Then try to explain again what your real problem is.

Chelley

Chelley
  • Members
  • 43 posts

Posted 22 October 2004 - 15:12

OK the initial problem is that OnUIBefore and OnUIAfter scripts are not executed if running in silent mode.

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 25 October 2004 - 20:35

Well, a silent setup shouldn't display dialogs, so that makes sense. But you can put any other function that you need to run in silent mode in one of the other event handlers.