0

My installation concludes by informing the user that the file has been extracted, but when accessing the folder, there is no extracted file, it just opens the winrar screen displaying the contents of the file on the screen.

procedure CurStepChanged(CurStep: TSetupStep);
var
 filename  : string;
 ErrorCode: Integer;
begin

filename := expandconstant('{tmp}\InstalaPlaylistClassic.zip');
MsgBox('O arquivo foi baixado com sucesso, estou em CurStepChanged: '+ filename + chr(13) , mbError, mb_Ok);

if CurStep=ssInstall then begin //Lets install those files that were downloaded for us
    MsgBox('Verificando se o arquivo existe ', mbError, mb_Ok);
    if fileExists(filename) then begin          // foi baixado. Executar o instalador do fw. 
      MsgBox('O arquivo existe ' + filename + chr(13) + SysErrorMessage(ErrorCode), mbError, mb_Ok);
      MsgBox('Chamando procedure unzip ', mbError, mb_Ok);
      ExtractMe(ExpandConstant('{tmp}\InstalaPlaylistClassic.zip'),ExpandConstant('{userappdata}\ccc\extracted'));
      if not ShellExec('', filename,'', '', SW_SHOW, ewWaitUntilTerminated, ErrorCode) then begin
          MsgBox('Houve algum problema ', mbError, mb_Ok);
      // Xi! Deu erro
        if ErrorCode <> 0 then begin
              MsgBox('Erro ao executar o arquivo ' + filename + chr(13) + SysErrorMessage(ErrorCode), mbError, mb_Ok);
      end
      end
    end
end

end;

const
 SHCONTCH_NOPROGRESSBOX = 4;
 SHCONTCH_RESPONDYESTOALL = 16;

 procedure Unzip(ZipFile, TargetFolder: String); 
 var
   ShellObj, SrcFile, DestFolder: Variant;
 begin
   ShellObj := CreateOleObject('Shell.Application');
   SrcFile := ShellObj.NameSpace(ZipFile);
   DestFolder := ShellObj.NameSpace(TargetFolder);
   DestFolder.CopyHere(SrcFile.Items, SHCONTCH_NOPROGRESSBOX or SHCONTCH_RESPONDYESTOALL)
   MsgBox('Arquivo extraído', mbError, mb_Ok);
 end;

procedure ExtractMe(src, target : String); 
begin
   MsgBox('Entrei em ExtractMe, vou tentar extrair ', mbError, mb_Ok);
   Unzip(ExpandConstant(src), ExpandConstant(target));
end;

In order for me to continue the process of installing my program, I need this file to be really extracted to the folder and I don't understand how to do that.

Thank you for any help

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
bruno
  • 9
  • 3
  • Does this answer your question? [How to get Inno Setup to unzip a file it installed (all as part of the one installation process)](https://stackoverflow.com/questions/6065364/how-to-get-inno-setup-to-unzip-a-file-it-installed-all-as-part-of-the-one-insta) – Andrew Truckle Nov 22 '19 at 10:14
  • Did you actually check the `{userappdata}\ccc\extracted` folder? I guess the ZIP file is actually extracted there. -- Your `ShellExec` call opens Windows explorer with the ZIP file (`filename`). While you probably wanted to open the `{userappdata}\ccc\extracted` folder. – Martin Prikryl Nov 22 '19 at 10:19
  • yes ... it's really extracting the file in the folder "userAppData \ Roaming \ ccc \ extracted" I need to change this path to the C directory of the machine, but the error is displayed "NIL INTERFACE EXCEPTION" – bruno Nov 22 '19 at 10:47
  • Show us the code for that. – Martin Prikryl Nov 22 '19 at 11:12
  • ExtractMe(ExpandConstant('{tmp}\InstalaPlaylistClassic.zip'),ExpandConstant('{sd}\InstalaPlaylistClassic')); – bruno Nov 22 '19 at 11:18
  • If possible, I would like the file to be extracted to the folder that the user downloaded. For example, if he used google chrome, then it will be under "Downloads." – bruno Nov 22 '19 at 11:20
  • Does the `InstalaPlaylistClassic` folder exists? – Martin Prikryl Nov 22 '19 at 12:22
  • yes ... and it is inside the zipped file. – bruno Nov 22 '19 at 13:12
  • No, it was meant as if the path like `C:\InstalaPlaylistClassic` exists. It seems it does not; I guess that *"nil interface exception"* exception is raised for the `CopyHere` method call on the `DestFolder` interface in `nil` state (because `NameSpace` returns `nil` for non existing directory). Do note, that the target directory must exist at the time of unpacking (not inside the archive but on the target drive). – TLama Nov 22 '19 at 13:50
  • Would you have any way to create this destination directory before extracting the file? Could you give me some help on how to do this? – bruno Nov 22 '19 at 17:00
  • To create a directory use the [CreateDir](http://www.jrsoftware.org/ishelp/topic_isxfunc_createdir.htm) function. – TLama Nov 23 '19 at 09:00
  • It worked, but now testing on other computers, the download is not completed. Was there any reason for that? On the computer where InnoSetup is installed it downloads and installs normally, but not the others. – bruno Nov 23 '19 at 21:44

0 Answers0