none
"Self Extracting Executable" - C#

    Question

  • Hi everyone!

    I have been looking for a way to create my own "self extracting executable"-solution in C#.

    What do I wish to achieve? - I wish to create an separate .exe from my original program. This new exe will have embedded resources to it, that I wish to "extract". So, how can I do this? I have been thinking of doing this by using "ICodeCompiler" and write the code as strings, add resources, and then compile it... but, that is a rather "impractical" solution?

    Why don't I just use a .zip library? -Well, there is two reasons. 1) I wish to have my own GUI interface on the "sfx". 2) I need to modify the datastream on the resource extraction - for decryption.

    Possible solution? - Can I for example create a .exe, with functions as needed in my "sfx" (ex. loop throw all its resources and extract them), and then do some "late adding of resources" to this already compiled .exe?


    -Regards Luntarn
    //You have to excuse my poor English (and/or) bad explanation of the problem - if that is the case, I think this fellow (who wish, I gather, to achieve the very same thing)  might describe it a bit better:
    http://www.netframeworkdev.com/common-language-runtime/programatically-embedding-resources-a-la-selfextracting-zip-archive-42745.shtml

    Sunday, September 26, 2010 8:58 PM

Answers

  • You might be able to do the following:

    You could use ILMerge to add the data resources to your executable later (http://research.microsoft.com/en-us/people/mbarnett/ilmerge.aspx). That way you can create an assembly with the executable code in it (your sfx.exe) and you create an assembly with the data you want to extract int it (either as separate resources or as a compressed and encrypted data stream). If give this resource a fixed name or a fixed prefix, you should be able to find it after the merge and extract the data from it.

    • Marked as answer by LuntarN Monday, September 27, 2010 5:35 PM
    • Unmarked as answer by LuntarN Tuesday, September 28, 2010 3:54 PM
    • Marked as answer by LuntarN Thursday, September 30, 2010 6:28 PM
    Monday, September 27, 2010 8:24 AM

All replies