self extracting zip taking arguments
Asked Answered
V

4

5

I am looking for a tool that will allow me to create a self extracting executable file which can take arguments. The arguments will later be passed on to the batch file that is residing within the package that the self extracting exe contains.

Here is what I would want to achieve in steps:

User types: cmd>setup.exe arg1 arg2 arg3 arg4 arg5

Expected behavior: 1) setup.exe extracts its contents to some folder 2) it then goes and executes a batch file with arg1, arg2,...arg5 arguments

Is anyone aware of a tool like that ?

Vignette answered 29/6, 2012 at 3:53 Comment(0)
V
3

I was able to achieve it using WinRar. So thanks for the advice. User can specify what executable to launch after files are being extracted. Command line arguments are saved in an environment variable %sfxcmd%. So if you put that environment variable right next to the executable the arguments will be passed to it. The arguments may later be passed within your executable.

Vignette answered 9/7, 2012 at 2:51 Comment(0)
U
3

Don't know if it could help but WinRAR lets you create auto-exe-extracting files, besides it gives you the option to run some command after the extraction and/or to show you a license info in a text editor

Uteutensil answered 29/6, 2012 at 4:6 Comment(0)
V
3

I was able to achieve it using WinRar. So thanks for the advice. User can specify what executable to launch after files are being extracted. Command line arguments are saved in an environment variable %sfxcmd%. So if you put that environment variable right next to the executable the arguments will be passed to it. The arguments may later be passed within your executable.

Vignette answered 9/7, 2012 at 2:51 Comment(0)
I
2

It's also possible to do this with 7zip. I first created a .7z package, then used the "SFX modules for installers" to convert it to a self-extracting zip. This allows you to specify in a config file which file to launch after extracting. If you pass parameters to the self-extracting zip, they will be passed to the file that you specified. The downside of this approach is that there is no way to specify the icon used for the zip.

More details are available in this question

Implode answered 1/1, 2013 at 6:36 Comment(2)
Thank you. 7zip is a free solution, so some people might choose to go with that. WinRAR on the other hand, is not free. But the good part about it is that if you create a self extracting executable you can freely distribute it. Because essentially you are not redistributing WinRAR itself but the self extracting executable. My company went with the WinRAR solution. It was easy to use and easy to automate without using the UI within a batch file. But, nevertheless, thanks for your input and the link !Vignette
You can use ResourceHacker from angusj.com/resourcehacker to change the icon. Easiest is to do this in the sfx file. Windows detects 7z sfx files as being setups, so it'll default it to require administrator privileges. You can also use ResourceHacker to add a manifest to force it to run as invoker.Ovum
M
1

Use WinRar. The parameters can be passed using the -sp option.

http://www.winrar-tr.com/winrar/Help/ENG/html/HELPGUISFXCmd.htm

myexe.exe -spoptions

"options" will be passed to the program in the setup field of the executable.

Milestone answered 9/4, 2014 at 20:1 Comment(1)
If you already had some arguments specified while creating the sfx, they will be replaced. To pass multiple arguments use myexe.exe "-sparg1 arg2"Leolaleoline

© 2022 - 2024 — McMap. All rights reserved.