Announcement

Collapse
No announcement yet.

InnoSetup starting a PB program before updating

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mike Doty
    replied
    Install a pre-installation program with InnoSetup and shell to it before installing other files.
    This allows different checks or performing new actions if required with any version.
    A splash screen is optional pbwin10\samples\sdk\hellowin

    This should have an option to terminate the install.
    Change (Code) to bracket Code bracket

    Code:
    [Files]
    Source: splash.exe; DestDir: {app}; Flags: ignoreversion overwritereadonly; AfterInstall:PowerBasicPreInstall
    
    
    (Code)
    procedure PowerBasicPreInstall();
    var
    ErrorCode: INTEGER;
    begin
      //ShellExec('', ExpandConstant('{app}\splash.exe'),'', '', SW_SHOW, ewNoWait, ErrorCode);
      ShellExec('', ExpandConstant('{app}\splash.exe'),'', '', SW_SHOW, ewWaitUntilTerminated, ErrorCode);
      //MsgBox('This is not needed', mbInformation, MB_OK);
    end;

    Leave a comment:


  • Michael Mattias
    replied
    I don't run a program at start; I call a function in a PB-Created DLL.

    This code ensures the correct minimum version of the software is installed and that no instances are running; and it re-serializes the new EXE with the user's existing serial number.

    Since I'm not a Pascal programmer I do all the really neat stuff in a function in a PB-Created DLL.


    Code:
    var
       ResultCode: Integer;
    //        "During Setup, a special 'files:' prefix to instruct Setup to automatically extract the DLL from the
    //       [Files] section may also be used.
    function TsiUpgradeCheck (szTmp, szParam, szSpare: String): Integer;
    external '[email protected]:tsiupgrade.dll';
    
    
    function InitializeSetup(): Boolean;
    var
    	sFile: String;
    	sFullFile: String;
    	sMsg : String;
    	sTmp    : String;
    	sSpare  : String;
    	bMsgBox : Boolean;
    	iZero   : Integer;
    	iOne    : Integer;
    	iTwo    : Integer;
    	iThree  : Integer;
    	iFour   : Integer;
    	iFive   : Integer;
    	bMutex  : Boolean;
    	
    begin
     //
     bMutex     := CheckForMutexes ('provider_payment_partner_v_300');
    
     if bMutex = True then
     begin
           sMsg    := 'Cannot run upgrade - PPPS is currently executing.';
           msgbox (sMsg,mbCriticalError, MB_OK);
           Result  := False;
           bMsgbox := False;
    
     end;
     if bMutex = False then
     begin
        iZero      := 0;
        iOne       := 1;
        iTwo       := 2;
        iTHree     := 3;
        iFour      := 4;
        iFive      := 5;
        sFile      := 'ppps.exe';           // file to be extracted to {tmp}: the DLL will need it
        sFullFile  :=  ExpandConstant('{tmp}\'+ sFile)
        sTmp       :=  ExpandConstant('{tmp}')
        sSpare     := 'log=pppsupgrade.log'
    
        // get the new PPPS.EXE into {tmp}
        ExtractTemporaryFile (sFile)
        // CALL the UpgradeCheck function. Returns zero if OK to continue.
        // this function with this parameter is looking for 3.0 to be installed.
        // which is exactly what we want.
        // I think for 3.2 I want to also check for 3.2 installed.
        // TsiUpgradeCheck does what...?
        //
        ResultCode :=  TsiUpgradeCheck (sTmp,'PPPS300',sSpare);   // key for PPPS 3x3x upgrade
        // old exec code was here
        // I could check here if not zero, then retry with PPPS 310?
        if ResultCode > 0 then
        begin
            ResultCode :=  TsiUpgradeCheck (sTmp, 'PPPS310', sSpare)
        end;
        // I think just adding this code will work for upgrade
        if ResultCode > 0 then
        begin
            ResultCode := TsiUpgradeCheck (sTmp, 'PPPS320', sSpare)
        end;
        // at this point if ResultCode = 0 then at least one of 3.0, 3.1 or 3.2 is installed and we may proceed.
        case ResultCode of
                  iZero:
                     Result  := True
                  //  1 = not installed
                  iOne :
                    begin
                      sMsg    := 'Neither PPPS version 3.0, 3.1 or 3.2 is installed on this system. Cannot upgrade.'
                      bMsgBox :=  True
                      Result  :=  False
                    end
                   // 2 = installed EXE not found where it belongs
                   iTwo :
                    begin
                      sMsg    := 'Cannot find installed PPPS.EXE in correct folder'
                      bMsgBox := True
                      Result  := False
                    end
                   // 3=  {tmp} exe not found (this is REALLY bad)
                   iThree :
                    begin
                      sMsg    := 'Cannot find PPPS.EXE in {tmp} Folder'
                      bMsgBox := True
                      Result  := False
                    end
                   //   1.03.06 we can no longer get RC 4 or 5 here.
                   // 4 = invalid USN
                   iFour :
                    begin
                      sMsg    := 'Invalid or Missing Serial Number'
                      bMsgBox := True
                      Result  := False
                    end
                   // 5 = can't update USN block
                   iFive :
                    begin
                      sMsg    := 'Unable to serialize new program file'
                      bMsgBox := True
                      Result  := False
                    end
                   else
                     begin
                        sMsg    := 'Return code ' + IntToStr (ResultCode)
                        Result  := False
                        bMsgBox := True
                     end
        end;             // end of case
    
    
        if bMsgbox = True then
           begin
              sMsg    := sMsg + '. Contact TSI Support for assistance'
              msgbox (sMsg,mbCriticalError, MB_OK)
           end
      end;     // end of if bMutex = false's begin
    
    end;
    MCM

    Leave a comment:


  • Mike Doty
    replied
    Thanks much, MM!

    Leave a comment:


  • Michael Mattias
    replied
    [CODE] Section of script, InitializeSetup event.

    Leave a comment:


  • Mike Doty
    started a topic InnoSetup starting a PB program before updating

    InnoSetup starting a PB program before updating

    How would I run or shell to a PB program before InnoSetup starts updating?

    I want to backup a folder, test the backup and assure nobody is using anything before updating.

    [Run] with a flag within InnoSetup?
    Last edited by Mike Doty; 10 May 2009, 09:08 AM.
Working...
X