For example, I want to put a deployment of an application which includes setup.exe
into a self-extracting archive. When the user executes the self-extracting archive it'll unzip the contents to a temp folder and run setup.exe.
Is this possible? If so, any examples?
yes, that's one of the things you can do with DotNetZip
.
The doc page provides an example.
SaveSelfExtractor Method (exeToGenerate, options)
string DirectoryPath = "c:\\Documents\\Project7";
using (ZipFile zip = new ZipFile())
{
zip.AddDirectory(DirectoryPath, System.IO.Path.GetFileName(DirectoryPath));
zip.Comment = "This will be embedded into a self-extracting WinForms-based exe";
var options = new SelfExtractorSaveOptions
{
Flavor = SelfExtractorFlavor.WinFormsApplication,
DefaultExtractDirectory = "%USERPROFILE%\\ExtractHere",
PostExtractCommandLine = ExeToRunAfterExtract,
SfxExeWindowTitle = "My Custom Window Title",
RemoveUnpackedFilesAfterExecute = true
};
zip.SaveSelfExtractor("archive.exe", options);
}