自己抽出SFXアーカイブを作成します

Aspose.Zipを使用すると、自己抽出(SFX)アーカイブを作成できます。 これは特別な種類のziptedファイルで、fileName拡張子があります。ダブルクリックして、自己抽出ファイルを解凍できます。

作成自己抽出アーカイブ

自己抽出アーカイブを構成するには、 自己抽出型をインスタンス化し、保存時に archivesaveoptionsに渡します。

1try(fileoutputStream zipfile = new fileoutputStream( "archive.exe")){
2    try(archive archive = new archive()){
3        archive.createentry( "entry.bin"、​​ "data.bin");
4        ArchivesAveOptions options = new archivesaveoptions();
5        options.setselfextractoroptions(new selfextractoroptions());
6        archive.save(zipfileoptions);
7    }
8} catch(ioException ex){
9}

自己抽出アーカイブの実行

作成するアーカイブは実行可能であり、実行するには.NETフレームワーク2.0以上が必要です。このようなフレームワークには、Windows Vista以上が付属されています。 ダブルクリックして通常のプログラムとして実行するか、コマンドラインインターフェイスを介して実行することができます。 抽出を開始する場合は、 -autoextractコマンドラインオプションを自動的に指定します。サンプル:

1C:\>archive.exe -autoExtract -password:T0p$ecret

自己抽出アーカイブのコマンドラインオプション

OptionMeaningSample
-autoExtract

Primary option - without it decompression does not start.

Extraction starts automatically, other options apply.

sfx.exe -autoExtract
-autoCloseWindow closes when the extraction is complete. This option only makes sense if -autoExtract option is present.sfx.exe -autoExtract -autoClose
-forceOverwriteOverwrites 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"

これらのオプションを使用して、Windowsでバッチスクリプトを作成できます。

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.