Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

7zsd.sfx with encryption

2011-05-25
2012-12-07
  • Anthony Gotts
    Anthony Gotts
    2011-05-25

    Hi,

    I have been using the 7zip utility for quite a while now and would like to create a self extracting file with encryption. I can do this with the command:

    7z a -ppassword -mhe -sfx7z.sfx Archive_Name.exe *.*

    However as far as I can gather this method will prompt the user for an extraction location upon execution…Instead I would like to set a default extraction location using the config.txt +7zSD.sfx method. However this method does not seem to support encryption. I have tried the following but get the error "Non 7z archive"

    7z a -ppassword -mhe Archive_Name.7z *.*

    copy /b 7zSD.sfx + config.txt + Archive_Name.7z Archive_Name_To_Exe.exe

    Where all the files are in the same folder and config.txt is given by

    ;!@Install@!UTF-8!
    InstallPath="C:\\Default_Folder_To_Extract_To"
    GUIMode="1"
    SelfDelete="1"
    ;!@InstallEnd@!

    So am I missing something or is it in fact not possible to create an encrypted self extraction file that will extract to a default location?

    Thanks

    7z version 4.65
    Windows XP Service Pack 3
    Intel Celeron M Processor
    1MB RAM

    Gauss76

     
  • Igor Pavlov
    Igor Pavlov
    2011-05-25

    you can use
    Small SFX modules for installers 7zS2.sfx
    combine it with archive a.7z.
    a.7z must contain:
    a.exe - sfx file with your files.
    and
    setup.bat

    setup.bat:
    a.exe x -oc:\dir1

     
  • Anthony Gotts
    Anthony Gotts
    2011-05-25

    OK,

    Problem number one is that I cannot find 7zS2.sfx anywhere?

    Gauss76

     
  • jose_chingasos
    jose_chingasos
    2011-05-25

    gauss,
    7zS2.sfx is in the 7z922_extra.7z at sourceforge.

     
  • Anthony Gotts
    Anthony Gotts
    2011-05-25

    OK

    Thanks, got it now. But I am still using version 4.65 of 7zip is this ok?…If it is then I still cannot get it to do what I want. Can anymore give me the steps one by one?

    Thanks

    Gauss76

     
  • Anthony Gotts
    Anthony Gotts
    2011-05-25

    This is what I have tried so far:

    A.) No Encryption

    1.) 7z a a.7z *.xls
    2.) copy /b 7zSD.sfx + config.txt + a.7z a.exe
    3.) 7z a a2.7z a.exe
    4.) copy /b 7zS2.sfx + a2.7z a3.exe

    Where the config.txt contains the default extract path. This works! now for the encryption part

    B.) With Encryption

    1.) 7z a -ppassword -mhe a.7z *.xls
    2.) copy /b 7zSD.sfx + config.txt + a.7z a.exe
    3.) 7z a a2.7z a.exe
    4.) copy /b 7zS2.sfx + a2.7z a3.exe

    This gives an error. I tried moving the password part from step 1.) to step 3.) but still get an error!

    Gauss76

     
  • Ken
    Ken
    2011-11-16

    Here's how I did it with my specific file, based 100% on IPavlov's post:

    1) Using the 7zFM.exe file manager, I created an encrypted sfx file of the files I need.  I imagine you could do this with the normal 7z -sfx switch as Igor mentions above, but not with 7zsd +config.txt, etc as everyone, including me has been trying to do.  I called mine (testinstall.exe)
    2) Create the batch file that opens the sfx from #1 without prompts, or whatever you need.  (testinstall.exe x -oc:\temp)
    3) Combine 1 and 2 as a normal 7z archive using either the file manager or 7z/7za.exe
    4) Create a Config.txt for the final SFX archive

    ;!@Install@!UTF-8!
    RunProgram="testinstall.exe /s"
    GUIMode="2"
    ;!@InstallEnd@!
    

    5) Combine 3 and 4

    copy /b 7zsd.sfx + Config.txt + testzip.7z result.exe
    

    This is basically the same thing that IPavlov posted, just wanted to show that it definitely works with my example.  Gauss76, I think your error comes from using 7zsd in the first sfx instead of just using 7z -sfx to create it with no Config.txt.  The Config.txt should probably be only with the second sfx.