Crear archivos SFX autoextraíbles
Aspose.ZIP permite crear un archivo autoextraíble (SFX). Se trata de un tipo especial de archivo comprimido, que tiene una extensión de nombre de archivo .exe. Puede descomprimir un archivo autoextraíble haciendo doble clic en él.
Creación de un archivo autoextraíble.
Para componer un archivo autoextraíble instancie SelfExtractorOptions y páselo a ArchiveSaveOptions al guardar.
1try (FileOutputStream zipFile = new FileOutputStream("archive.exe")) {
2 try (Archive archive = new Archive()) {
3 archive.createEntry("entrada.bin", "datos.bin");
4 ArchiveSaveOptions options = new ArchiveSaveOptions();
5 options.setSelfExtractorOptions(new SelfExtractorOptions());
6 archive.save(zipFile, options);
7 }
8} catch (IOException ex) {
9}
Ejecutando archivo autoextraíble
El archivo que produce es ejecutable y requiere .NET Framework 2.0 o superior para ejecutarse. Dichos marcos se suministran con Windows Vista y superior.
Puede ejecutarlo como un programa normal haciendo doble clic, o ejecutarlo a través de la interfaz de línea de comandos.
Si desea iniciar la extracción automáticamente, especifique la opción de línea de comandos -autoExtract
. Ejemplo:
1C:\>archive.exe -autoExtract -password:T0p$ecret
Opciones de línea de comandos para archivos autoextraíbles.
Option | Meaning | Sample |
---|---|---|
-autoExtract | Primary option - without it decompression does not start. Extraction starts automatically, other options apply. | sfx.exe -autoExtract |
-autoClose | Window closes when the extraction is complete. This option only makes sense if -autoExtract option is present. | sfx.exe -autoExtract -autoClose |
-forceOverwrite | Overwrites all existing files without prompt if there are any. This option only makes sense if -autoExtract option present. | sfx.exe -autoExtract -forceOverwrite |
-password: | Provides a password to encrypted entries. This option only makes sense if -autoExtract option is present. If you have spaces within the password quote it. | sfx.exe -autoExtract -password:T0p$ecret |
-destination: | Extracts files to the supplied directory. This option only makes sense if -autoExtract option is present. If you have spaces within the path quote it. | sfx.exe -autoExtract -destination:"C:\My Documents" |
Puede utilizar estas opciones para componer Batch Script en Windows.