//////////////////////////////////////////////////////////////////////////////// // // File Name: Setup.rul // // Description: InstallShield script // // Comments: This script was generated based on the selections you made in // the Project Wizard. Refer to the help topic entitled "Modify // the script that the Project Wizard generates" for information // on possible next steps. // //////////////////////////////////////////////////////////////////////////////// // Include header files #include "ifx.h" ////////////////////// string defines //////////////////////////// //////////////////// installation declarations /////////////////// // ----- DLL function prototypes ----- // your DLL function prototypes // ---- script function prototypes ----- // your script function prototypes prototype rs(BYREF STRING); prototype SetPermissions(); prototype CheckJava(); // your global variables STRING svAdminPassword; STRING javadir; // for _LaunchAppEx function #ifndef STILL_ACTIVE #define STILL_ACTIVE 0x00000103 #endif #if _ISCRIPT_VER < 0x600 #ifndef BYVAL #define BYVAL #endif #endif prototype _LaunchAppEx(STRING, STRING, NUMBER, NUMBER, NUMBER, BYREF NUMBER); prototype BOOL kernel32.CreateProcessA(POINTER, BYVAL STRING, POINTER, POINTER, BOOL, NUMBER, POINTER, POINTER, POINTER, POINTER); prototype BOOL kernel32.GetExitCodeProcess(NUMBER, POINTER); prototype NUMBER kernel32.WaitForSingleObject(NUMBER, NUMBER); prototype BOOL kernel32.CloseHandle(HWND); typedef STARTUPINFO begin NUMBER cb; POINTER lpReserved; POINTER lpDesktop; POINTER lpTitle; NUMBER dwX; NUMBER dwY; NUMBER dwXSize; NUMBER dwYSize; NUMBER dwXCountChars; NUMBER dwYCountChars; NUMBER dwFillAttribute; NUMBER dwFlags; NUMBER wShowWindow; POINTER lpReserved2; HWND hStdInput; HWND hStdOutput; HWND hStdError; end; typedef PROCESS_INFORMATION begin NUMBER hProcess; HWND hThread; NUMBER dwProcessId; NUMBER dwThreadId; end; ////////////////////////////////////////////////////////////////////////////// // // FUNCTION: OnFirstUIBefore // // EVENT: FirstUIBefore event is sent when installation is run for the first // time on given machine. In the handler installation usually displays // UI allowing end user to specify installation parameters. After this // function returns, FeatureTransferData is called to perform file // transfer. // /////////////////////////////////////////////////////////////////////////////// function OnFirstUIBefore() number nResult; string szTitle, szMsg, szField1; string szLicenseFile, szQuestion; string szDir; string szFeatures, szTargetdir; string svSetupType; string svName; number nLevel; LIST listInfo; number nvSize; 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; szDir = INSTALLDIR; Dlg_Start: // beginning of dialogs label Dlg_SdWelcome: szTitle = ""; szMsg = ""; nResult = SdWelcome( szTitle, szMsg ); if (nResult = BACK) goto Dlg_Start; Dlg_SdLicense: szLicenseFile = SUPPORTDIR ^ "license.txt"; szTitle = ""; szMsg = ""; szQuestion = ""; nResult = SdLicense( szTitle, szMsg, szQuestion, szLicenseFile ); if (nResult = BACK) goto Dlg_SdWelcome; Dlg_SdAskDestPath: szTitle = ""; szMsg = ""; nResult = SdAskDestPath( szTitle, szMsg, szDir, 0 ); INSTALLDIR = szDir; if (nResult = BACK) goto Dlg_SdLicense; Dlg_SetupType: szTitle = ""; szMsg = ""; svSetupType = "LocalLibrary"; nResult = SdSetupTypeEx ( szTitle , szMsg , "" , svSetupType , 0 ); if (nResult = BACK) goto Dlg_SdAskDestPath; Dlg_SdFeatureTree: szTargetdir = INSTALLDIR; nLevel = 2; nvSize = 256; MsiGetProperty (ISMSI_HANDLE, "ISReleaseFlags", svName, nvSize); // show the full feature tree if doing a custom install or // just the list of collections if not if (svSetupType = "Custom") then szFeatures = ""; szTitle = ""; szMsg = ""; nResult = SdFeatureTree(szTitle, szMsg, szTargetdir, szFeatures, nLevel); elseif (svName % "CDROM_ONLY") then szFeatures = "Collections"; szTitle = @TEXT_SELECT_COLLECTIONS; szMsg = @TEXT_SELECT_COLLECTIONS_DESC; nResult = SdFeatureTree(szTitle, szMsg, szTargetdir, szFeatures, nLevel); endif; if (nResult = BACK) goto Dlg_SetupType; // if the GLI is selected we need to make sure java is installed - bail // out of installation with a warning if it's not (if this function // returns it will have set the javadir global) /* if (svName % "GLI") then if (CheckJava()=FALSE) then listInfo = ListCreate(STRINGLIST); ListAddString(listInfo, @TEXT_NOJAVA_01, AFTER); ListAddString(listInfo, @TEXT_NOJAVA_02, AFTER); ListAddString(listInfo, @TEXT_NOJAVA_03, AFTER); ListAddString(listInfo, @TEXT_NOJAVA_04, AFTER); ListAddString(listInfo, @TEXT_NOJAVA_05, AFTER); ListAddString(listInfo, @TEXT_NOJAVA_06, AFTER); ListAddString(listInfo, @TEXT_NOJAVA_07, AFTER); ListAddString(listInfo, @TEXT_NOJAVA_08, AFTER); ListAddString(listInfo, @TEXT_NOJAVA_09, AFTER); ListAddString(listInfo, @TEXT_NOJAVA_10, AFTER); SdShowInfoList(szTitle, szMsg, listInfo); ListDestroy(listInfo); // don't install the GLI - java not found FeatureSelectItem(MEDIA, "GLI", FALSE); endif; endif; */ Dlg_SdDlgEdit1: // get the admin password from the user svAdminPassword = "admin"; // the default szTitle = @TEXT_ADMIN_PW; szMsg = @TEXT_ADMIN_PW_DESC; szField1 = @TEXT_PW; nResult = SdShowDlgEdit1(szTitle, szMsg, szField1, svAdminPassword); if (nResult = BACK) goto Dlg_SdFeatureTree; Enable(STATUSEX); return 0; end; /////////////////////////////////////////////////////////////////////////////// // // FUNCTION: OnMaintUIBefore // // EVENT: MaintUIBefore event is sent when end user runs installation that // has already been installed on the machine. Usually this happens // through Add/Remove Programs applet. In the handler, installation // usually displays UI allowing end user to modify existing installation // or uninstall application. After this function returns, // FeatureTransferData is called to perform file transfer. // /////////////////////////////////////////////////////////////////////////////// function OnMaintUIBefore() NUMBER nResult, nType; STRING szTitle, szMsg, svDir, svResult, szCaption; 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 ); // SetColor(BACKGROUND,RGB (0, 128, 128)); // Enable( FULLWINDOWMODE ); // Enable( BACKGROUND ); // MessageBox(@TEXT_INSTALLED_1 + "\n" + // @TEXT_INSTALLED_2 + "\n" + // @TEXT_INSTALLED_3, INFORMATION); // exit; Dlg_Start: Disable(BACKBUTTON); nType = SdWelcomeMaint(szTitle, szMsg, MODIFY); Enable(BACKBUTTON); if (nType = REMOVEALL) then svResult = SdLoadString(IFX_MAINTUI_MSG); szCaption = SdLoadString(IFX_ONMAINTUI_CAPTION); nResult = SprintfBox(MB_OKCANCEL,szCaption,"%s",svResult); if (nResult = IDCANCEL) goto Dlg_Start; endif; nResult = NEXT; Dlg_SdFeatureTree: if (nType = MODIFY) then szTitle = ""; szMsg = ""; nResult = SdFeatureTree(szTitle, szMsg, TARGETDIR, "", 2); if (nResult = BACK) goto Dlg_Start; endif; switch(nType) case REMOVEALL: ComponentRemoveAll(); case REPAIR: ComponentReinstall(); endswitch; Enable(STATUSEX); end; /////////////////////////////////////////////////////////////////////////////// // // FUNCTION: OnEnd // // EVENT: End event is the last event. It is not sent if the installation // has been aborted. In this case Abort event is sent // /////////////////////////////////////////////////////////////////////////////// function OnEnd() NUMBER nvSize; STRING svName; begin // if (MAINTENANCE = FALSE) then // offer to install collection organizer if this is a // CD-ROM release // nvSize = 256; // MsiGetProperty (ISMSI_HANDLE, "ISReleaseFlags", svName, nvSize); // if (svName % "CDROM_ONLY") then // if (AskYesNo(@TEXT_COLLORG, YES) == YES) then // we need to wait for this to complete just in case setup causes // the system to be rebooted (which it will on some systems in some // cirtumstances) // LaunchAppAndWait(SRCDIR ^ "windows_utilities" ^ "Organizer.exe", "", WAIT); // endif; // endif; // endif; end; // turn any backslashes in string into forward slashes function rs(svString) NUMBER i; begin for i = 0 to StrLength(svString) if (svString[i] = '\\') then svString[i] = '/'; endif; endfor; end; // if running NT/2000 we need to make the collect and tmp // directories and some contents of the etc directory writable // by all users (otherwise certain functions will only work // if Greenstone is run by someone with admin privileges) function SetPermissions() STRING szProgram, szCmdLine, svResult; NUMBER nvExitCode, nvResult; begin GetSystemInfo( OS, nvResult, svResult ); if (nvResult = IS_WINDOWSNT) then szProgram = WINSYSDIR ^ "cmd.exe"; szCmdLine = "/c cacls \"" + INSTALLDIR ^ "tmp\" /E /G Everyone:F"; _LaunchAppEx(szProgram, szCmdLine, WAIT, SW_HIDE, 5000, nvExitCode); szCmdLine = "/c cacls \"" + INSTALLDIR ^ "collect\" /E /G Everyone:F"; _LaunchAppEx(szProgram, szCmdLine, WAIT, SW_HIDE, 5000, nvExitCode); szCmdLine = "/c cacls \"" + INSTALLDIR ^ "etc" ^ "error.txt\" /E /G Everyone:F"; _LaunchAppEx(szProgram, szCmdLine, WAIT, SW_HIDE, 5000, nvExitCode); szCmdLine = "/c cacls \"" + INSTALLDIR ^ "etc" ^ "key.db\" /E /G Everyone:F"; _LaunchAppEx(szProgram, szCmdLine, WAIT, SW_HIDE, 5000, nvExitCode); szCmdLine = "/c cacls \"" + INSTALLDIR ^ "etc" ^ "users.db\" /E /G Everyone:F"; _LaunchAppEx(szProgram, szCmdLine, WAIT, SW_HIDE, 5000, nvExitCode); szCmdLine = "/c cacls \"" + INSTALLDIR ^ "etc" ^ "main.cfg\" /E /G Everyone:F"; _LaunchAppEx(szProgram, szCmdLine, WAIT, SW_HIDE, 5000, nvExitCode); szCmdLine = "/c cacls \"" + INSTALLDIR ^ "etc" ^ "history.db\" /E /G Everyone:F"; _LaunchAppEx(szProgram, szCmdLine, WAIT, SW_HIDE, 5000, nvExitCode); szCmdLine = "/c cacls \"" + INSTALLDIR ^ "etc" ^ "usage.txt\" /E /G Everyone:F"; _LaunchAppEx(szProgram, szCmdLine, WAIT, SW_HIDE, 5000, nvExitCode); endif; end; function _LaunchAppEx(szProgram, szCmdLine, nWait, nShow, nTimeOut, nvExitCode) STARTUPINFO siData; PROCESS_INFORMATION piData; begin siData.cb = 68; siData.lpReserved = NULL; siData.lpDesktop = NULL; siData.lpTitle = NULL; siData.dwX = 0; siData.dwY = 0; siData.dwXSize = 0; siData.dwYSize = 0; siData.dwXCountChars = 0; siData.dwYCountChars = 0; siData.dwFillAttribute = 0; siData.dwFlags = 1; siData.wShowWindow = nShow; siData.lpReserved2 = NULL; siData.hStdInput = NULL; siData.hStdOutput = NULL; siData.hStdError = NULL; if (CreateProcessA(NULL, szProgram + " " + szCmdLine, NULL, NULL, TRUE, 0, NULL, NULL, &siData, &piData) = 0) then return (-1); endif; if ( nWait != WAIT ) then nvExitCode = 0; return 0; endif; WaitForSingleObject(piData.hProcess, nTimeOut); GetExitCodeProcess(piData.hProcess, &nvExitCode); CloseHandle(piData.hProcess); CloseHandle(piData.hThread); return 0; end; /* function CheckJava() string ProductKey, svValue; number nvType, nvSize; BOOL javaok; LIST listID; string svTmp; number nvTmp; begin RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); // Start with the JDK to see if its installed javaok = FALSE; ProductKey = "SOFTWARE\\JavaSoft\\Java Development Kit"; if (RegDBGetKeyValueEx(ProductKey, "CurrentVersion", nvType, svValue, nvSize)=0) then // parse the version number and make sure it's at least version 1.4 listID = ListCreate(STRINGLIST); StrGetTokens (listID, svValue, "."); ListGetFirstString(listID, svTmp); StrToNum(nvTmp, svTmp); if (nvTmp>=1) then ListGetNextString(listID, svTmp); StrToNum(nvTmp, svTmp); if (nvTmp>=4) then javaok = TRUE; endif; endif; if (javaok) then javaok = FALSE; ProductKey = ProductKey + "\\" + svValue; if (RegDBGetKeyValueEx(ProductKey, "JavaHome", nvType, svValue, nvSize)=0) then javadir = svValue; javaok = TRUE; endif; endif; ListDestroy(listID); endif; // Failing that search for a more common JRE if (javaok=FALSE) then ProductKey = "SOFTWARE\\JavaSoft\\Java Runtime Environment"; if (RegDBGetKeyValueEx(ProductKey, "CurrentVersion", nvType, svValue, nvSize)=0) then // parse the version number and make sure it's at least version 1.4 listID = ListCreate(STRINGLIST); StrGetTokens (listID, svValue, "."); ListGetFirstString(listID, svTmp); StrToNum(nvTmp, svTmp); if (nvTmp>=1) then ListGetNextString(listID, svTmp); StrToNum(nvTmp, svTmp); if (nvTmp>=4) then javaok = TRUE; endif; endif; if (javaok) then javaok = FALSE; ProductKey = ProductKey + "\\" + svValue; if (RegDBGetKeyValueEx(ProductKey, "JavaHome", nvType, svValue, nvSize)=0) then javadir = svValue; javaok = TRUE; endif; endif; ListDestroy(listID); endif; endif; RegDBSetDefaultRoot(HKEY_CLASSES_ROOT); if (javaok=FALSE) then return FALSE; endif; if (javadir[0]="\"") then StrSub(javadir, javadir, 1, StrLength(javadir)); endif; nvTmp = StrLength(javadir); if (javadir[nvTmp]="\"") then StrSub(javadir, javadir, 0, StrLength(javadir)-1); endif; LongPathToShortPath(javadir); StrRemoveLastSlash(javadir); return TRUE; end; */ #include "f:\gsdl_install\is7_gsdl_cdrom\Greenstone\featureevents.rul"