4

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 ?

santahopar
  • 2,933
  • 2
  • 29
  • 50

4 Answers4

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

higuaro
  • 15,730
  • 4
  • 36
  • 43
2

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.

santahopar
  • 2,933
  • 2
  • 29
  • 50
1

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

Community
  • 1
  • 1
jhewlett
  • 324
  • 3
  • 9
  • 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 ! – santahopar Feb 27 '13 at 02:13
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.

Matt_Bro
  • 14,062
  • 2
  • 28
  • 41
  • 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"` – toster-cx Nov 13 '15 at 20:53