I looked at the source code and this doesn't appear to be possible with DotNetZip. I'm now using 7zip to do this as indicated here
I also found this question, which says this is possible with WinRar.
문제
I created a self-extracting zip using DotNetZip with the following options:
var opts = new SelfExtractorSaveOptions();
opts.RemoveUnpackedFilesAfterExecute = true;
opts.PostExtractCommandLine = "TestApp.exe";
opts.Flavor = SelfExtractorFlavor.ConsoleApplication;
zip1.SaveSelfExtractor("TestAppSFX.exe", opts);
Is it possible to pass command line arguments to my self-extracting zip that will then be passed to the console application that gets invoked after extracting?
I.e., I want to be able to type something like the following:
TestAppSFX.exe -flag
Then, my console application TestApp.exe
would receive -flag
as an argument.
These arguments will vary depending on usage, so specifying them when I create the SFX is not an option.
다른 팁
Yes you can pass flags using DotNetZip, but you need to do a little work.
You need to download the source and modify CommandLineSelfExtractorStub.cs to accept you own custom arguments. Once you've done that, you can build it into a new stub exe.
To build your SFX you would do something like this...
byte[] stub = GetStubExecutable(); //read in your new stub file
output.Write(stub, 0, stub.Length);
using (ZipFile zip = new ZipFile())
{
String[] filenames = System.IO.Directory.GetFiles(Path.Combine(path,FilesFolder));
// Add the rest of they files you'd like in your SFX
foreach (String filename in filenames)
{
ZipEntry e = zip.AddFile(filename, OutputZipFolder);
}
zip.Save(output); // save the zip to the outputstream
}