Jump to content

[Tutorial] Making A 7-Zip Switchless Installer


ricktendo

Recommended Posts

Time for a new Tutorial. At first there are new versions of all the stuff that's needed. Secondly are there much improvements and is there an easier way to make a 7-Zip Installer now. Third: I think most people don't know this all.

Tutorial:

1. Download the right 7zSD (always linked to latest version). Extract and place the 7zsd.sfx in a new folder.

2. Go to here and download the 7za***.zip (where *** is the version number) from the latest 7-Zip command line version. Extract and place only the 7za.exe in the same folder as 7zSD.

3. Download UPX here. Extract and place only the upx.exe in the folder where 7zSD and 7za are placed.

4. Make a subdirectory with the name Bin and copy all installation files to.

5. If you want, you can change the icon of the installer by replacing the icon in 7zsd.sfx using ResHacker as described here.

6. You can also change the version info of the executable using ResHacker. Go to the folder Version Info in ResHacker by opening 7zsd.sfx and rename the values of "CompanyName" and "FileDescription".

7. Create a Config.txt in the same folder as 7zSD, 7za and UPX.

Open it and set:

RunProgram="program.exe -switch"

Replace program.exe with the name of your installer (including the extension). Replace -switch with the desired switch(es) to be used. Many switches of different programs can be found here.

For a full silent 7-Zip install you add:

GUIMode="2"

It's not needed any more to add StartX.exe, msistub.exe or other supplementary tools. Then "waiting" is enabled by default for 'RunProgram=', unless 'nowait:' parameter is used. Also reg-files aren't needed any more. They can be configured in the Config.txt.

For a Register Entry (If you use a lot of Register Entries it's smart to use the parameter SetEnvironment to save time):

RunProgram="hidcon:cmd Register Entry"

Keep this in mind: you MUST use DOUBLE backslashes (\\) wherever you normally use backslashes (\) (e.g. in paths or dialog texts). Similarly, if the Value contains double quotes ("), you MUST precede them with a backslash (\").

Now, your Config.txt looks like this:

;!@Install@!UTF-8!

GUIMode="2"

RunProgram="program.exe -switch"

RunProgram="hidcon:cmd Register Entry"

;!@InstallEnd@!

You can add, edit and remove lines if you want.

* All available configuration parameters and other helpful information can be found here (site is just translated from Russian to English).

8. Save Config.txt with UTF-8 encoding by selecting "UTF-8" from the dropdown menu in the "Save As..." dialog in Notepad.

9. Make a Create.cmd in the same folder as the Config.txt and past the following:

upx --ultra-brute 7zsd.sfx 
cd Bin
..\7za a -mx=9 "..\Program.7z" *
cd ..
copy /b 7zsd.sfx + Config.txt + Program.7z Program_Name.exe
del Program.7z

10. Rename Program_Name to your own program name and run your Create.cmd.

11. Congratulations: you have guaranteed the littlest 7-Zip Installer as possible.

Tool:

Utility that can extract 7z archive and config file (Config.txt) as well as SFX module (7zsd.sfx) from 7z SFX archive. It has the name 7z SFX Archive Splitter (from the 7z SFX creator) and you can download it here (always linked to latest version).

EnJoy. :D

Link to comment
Share on other sites

  • 2 weeks later...
  • 5 weeks later...

This works great for me but i have a question, say i wanted to copy a file/folder from the bin directory to the install directory of the app after i had run the install.. how would i do that?? For example i have some updated NOD32 files i want to add after running the install (replacing out of date ones) so i don't have to download them again.

Link to comment
Share on other sites

Thanks for the link and example! I tried that and it all worked well apart from ther are two files in the update folder "lastupd.var" ad "upd.var" its copying all the other files but those two are not getting over writen. could you kindly tell me how to delete/overwrite the two files, thanks ;-)

Link to comment
Share on other sites

1st Try these other xcopy switches (to see more in the CMD prompt type xcopy /?)

;!@Install@!UTF-8!
GUIMode="2"
RunProgram="setup.exe /s"
RunProgram="hidcon:cmd /c xcopy FolderName \"%ProgramFiles%\\FolderName\" /s /e /i /y /h /r /k"
;!@InstallEnd@!

2nd If that does not work try to rename the files before xcopy

;!@Install@!UTF-8!
GUIMode="2"
RunProgram="setup.exe /s"
RunProgram="hidcon:cmd /c ren \"%ProgramFiles%\\FolderName\\lastupd.var\" lastupd.bak"
RunProgram="hidcon:cmd /c ren \"%ProgramFiles%\\FolderName\\upd.var\" upd.bak"
RunProgram="hidcon:cmd /c xcopy FolderName \"%ProgramFiles%\\FolderName\" /s /e /i /y /h /r /k"
;!@InstallEnd@!

Link to comment
Share on other sites

Nice one, this code worked fine:

;!@Install@!UTF-8!
GUIMode="2"
RunProgram="setup.exe /s"
RunProgram="hidcon:cmd /c xcopy FolderName \"%ProgramFiles%\\FolderName\" /s /e /i /y /h /r /k"
;!@InstallEnd@!

I have now finished my first silent install and nlite addon now, thanks for your help ;-)

EDIT: can you please show me an example of how to add reg entries:

RunProgram="hidcon:cmd Register Entry"

I need to convert file this to the above format as it don't seem to work as a file:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Eset\Nod\CurrentVersion\Info]
"Build"="0x00002c76 (11382)"
"CurrentVersion"="2711 (20071207)"
"Date"="0x060c07d7 (101451735)"

The Build, and CurrentVersion need adding, the date needs updating. Sorry for all the questions.

EDIT: think i got it now:

RunProgram="hidcon:cmd REG ADD HKLM\SOFTWARE\Eset\Nod\CurrentVersion\Info /v Build /t REG_DWORD d/ 0x00002c76 (11382)"
RunProgram="hidcon:cmd REG ADD HKLM\SOFTWARE\Eset\Nod\CurrentVersion\Info /v CurrentVersion /t REG_SZ d/ 2711 (20071207)"
RunProgram="hidcon:cmd REG ADD HKLM\SOFTWARE\Eset\Nod\CurrentVersion\Info /v Date /t REG_DWORD d/ 0x060c07d7 (101451735) /f"

EDIT: sigh.. it don't seem to work if i do it from .reg file or config.txt... if i run the reg file or commands in windows it works.. why won't it work in the install?? What am i doing wrong?

Edited by DEViANCE
Link to comment
Share on other sites

  • 5 months later...

I cant find any switches on de UAwiki?

I need switches for:

- CCleaner --> /S

- Raxco PerfectDisk --> /qn

- Foxit Editor

Doing it right like this? Only need to fill in switches, im new with those silent installers.

;!@Install@!UTF-8!

GUIMode="2"

RunProgram="ccsetup207.exe -switch"

;!@InstallEnd@!

Edited by Raoul
Link to comment
Share on other sites

  • 5 months later...
and how to del any reg?
Will show you in my series of videos http://www.wincert.net/forum/index.php?showtopic=4659

Look inside SilentSwitchMaker you will find a CHM help file with an example of how to use REG DELETE with this, it goes something like this

RunProgram="InstallerName.exe /switch"
RunProgram="hidcon:reg delete \"hkcu\\Software\\Example\" /f"

Link to comment
Share on other sites

  • 2 weeks later...

Sorry for the stupid question... looks very complicated and need a lot of utilities to create a 7z Switchless Installer using this method, why not use the AutoIt method then a create 7zSFX or RARSFX, size will be more or less the same?

Link to comment
Share on other sites

Sorry for the stupid question... looks very complicated and need a lot of utilities to create a 7z Switchless Installer using this method, why not use the AutoIt method then a create 7zSFX or RARSFX, size will be more or less the same?

Heres a vid, will probably help explain a bit better

http://www.wincert.net/forum/index.php?showtopic=4659

Link to comment
Share on other sites

  • 10 months later...
  • 2 years later...
5. If you want, you can change the icon of the installer by replacing the icon in 7zsd.sfx using ResHacker as described here.

al editar opciones y guardar el antivirus me salta el exe como troyano?? como evito eso?

me pasa al cambiar el icono :S

EDIT: disculpen

Edited by jonydread
Link to comment
Share on other sites

  • 2 years later...

This tutorial is more than 6 years old, no wonder some links are dead !

@ricktendo: If you don't want/don't have time to update it, I can if you wish.

 

 

The 7zsd linked is the first post is a very old version, get latest stable version here: 7zSD

 

 

A cmd file is a text file with the extension changed, so you just have to create a new text file and paste the content, save it then change the file extension (*.txt to *.cmd)

 

 

About the content of the cmd file:

 

this

cd Bin..\7za a -mx=9 "..\Program.7z" *cd ..

can be simplified to this:

7za a "Program.7z" ".\Bin\*" -mx=9

So your cmd file look like this:

upx --ultra-brute 7zsd.sfx 7za a "Program.7z" ".\Bin\*" -mx=9copy /b 7zsd.sfx + Config.txt + Program.7z Program_Name.exedel Program.7z

The first line

upx --ultra-brute 7zsd.sfx 

is optional, (UPX is an executable compressor, this commands is used to compress 7zsd.sfx)

 

so your cmd file should only have these 3 lines for beginning:

7za a "Program.7z" ".\Bin\*" -mx=9copy /b 7zsd.sfx + Config.txt + Program.7z Program_Name.exedel Program.7z

Also, all the steps that involve Resource Hacker are optionals, you should first familiarize yourself with these things, then you can change the icon, etc....

 

 

 

Two SFX maker (if you prefer using a GUI):

http://sourceforge.net/projects/sfx-maker/

http://www.isoft-online.com/

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...