Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Create an exe which will produce other exe file

Create an exe which will produce other exe file

Scheduled Pinned Locked Moved .NET (Core and Framework)
hardwarehelpannouncementloungeworkspace
12 Posts 8 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Simon Bang Terkildsen

    Creating a Self Extracting Executable[^] Self-extracting ZIP[^] Personally I would go for the self extracting zip

    M Offline
    M Offline
    Musa Biralo
    wrote on last edited by
    #3

    Thanks for quick reply! You know the problem with SFX is I don't have any control. Let's say SFX contains 2 files and I only need to extract 1 depending on local computer condition, SFX won't work. I looked at the links provided and couldn't find a way to do certain action before extracting :( Thanks again though. I looked at these links however I could not compile them and I don't really know about C++. I wish I could take the dll and somehow manage to use... Creating a Self Extracting Executable[^] How to Write a Simple Packer/Unpacker with a Self-Extractor (SFX)[^] A Self-extracting Installer[^]

    1 Reply Last reply
    0
    • M Musa Biralo

      hi there, I like to write a program which will help a general person to create a new exe file. The first exe will add some files as resources and then creates an exe. The resulting exe will basically create the files initially added. It's something like creating a setup file but here we don't have to do anything other than reproducing the files which are embedded into an exe (like self extracting file). I can't use sfx file as i have to check certain thing in the target machine before extracting.... In short, a program that will create a very stripped down version of setup file something similar to SFX file. Thanks for sharing idea or point to right directions.

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #4

      Maybe a BAT file? :-D

      M 1 Reply Last reply
      0
      • P PIEBALDconsult

        Maybe a BAT file? :-D

        M Offline
        M Offline
        Musa Biralo
        wrote on last edited by
        #5

        hmmmm,a BAT file... Is there a way to store file(s) inside a BAT, which we can extract during execution? Plus I have to check conditions on a local machine which will be much difficult in from a BAT file from my understanding. If possible, i would like to use .NET applications...

        N D 2 Replies Last reply
        0
        • M Musa Biralo

          hmmmm,a BAT file... Is there a way to store file(s) inside a BAT, which we can extract during execution? Plus I have to check conditions on a local machine which will be much difficult in from a BAT file from my understanding. If possible, i would like to use .NET applications...

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #6

          Perhaps Powershell then, if supported on the target machines, to check the local machine and invoke a net app.


          I know the language. I've read a book. - _Madmatt

          modified on Monday, August 22, 2011 8:39 AM

          1 Reply Last reply
          0
          • M Musa Biralo

            hi there, I like to write a program which will help a general person to create a new exe file. The first exe will add some files as resources and then creates an exe. The resulting exe will basically create the files initially added. It's something like creating a setup file but here we don't have to do anything other than reproducing the files which are embedded into an exe (like self extracting file). I can't use sfx file as i have to check certain thing in the target machine before extracting.... In short, a program that will create a very stripped down version of setup file something similar to SFX file. Thanks for sharing idea or point to right directions.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #7

            Create an SFX that contains two files: An exe and a zip file (which contains all your files). The exe does the system checking and decides which files to extract and uses a zip utility to extract specific files from the zip archive.

            "Don't confuse experts with facts" - Eric_V

            1 Reply Last reply
            0
            • M Musa Biralo

              hi there, I like to write a program which will help a general person to create a new exe file. The first exe will add some files as resources and then creates an exe. The resulting exe will basically create the files initially added. It's something like creating a setup file but here we don't have to do anything other than reproducing the files which are embedded into an exe (like self extracting file). I can't use sfx file as i have to check certain thing in the target machine before extracting.... In short, a program that will create a very stripped down version of setup file something similar to SFX file. Thanks for sharing idea or point to right directions.

              A Offline
              A Offline
              Alan N
              wrote on last edited by
              #8

              If you can accept two files to send to the target machine your requirements could be met by 1) An application that allows the user to select files and store them into a resource only assembly (dll) 2) An application to do the checks on the target machine, read the resources and write them out as files. The resource only assembly is created by invoking the C# compiler, csc.exe, and the following command line will create resourcelib.dll containing two files FileInfo.txt and Help-Aug2011.chm csc /out:resourcelib.dll /target:library /resource:FileInfo.txt /resource:Help-Aug2011.chm The code needed to read the resources from the assembly and convert them back into files is fairly simple

              private void CreateFilesFromResources() {
              Assembly a = Assembly.LoadFile(@"E:\VC\Projects\CodingTests\BinaryResource\bin\Debug\resourcelib.dll");
              foreach (String filename in a.GetManifestResourceNames()) {
              Console.WriteLine("Resource name {0}", filename);
              using (Stream rs = a.GetManifestResourceStream(filename)) {
              using (FileStream fs = File.Create(filename)) {
              Byte[] buff = new Byte[8192];
              Int32 read;
              while ((read = rs.Read(buff, 0, buff.Length)) > 0) {
              fs.Write(buff, 0, read);
              }
              }
              }
              }
              }

              Hope that helps and has given you a few ideas. Alan.

              L 1 Reply Last reply
              0
              • A Alan N

                If you can accept two files to send to the target machine your requirements could be met by 1) An application that allows the user to select files and store them into a resource only assembly (dll) 2) An application to do the checks on the target machine, read the resources and write them out as files. The resource only assembly is created by invoking the C# compiler, csc.exe, and the following command line will create resourcelib.dll containing two files FileInfo.txt and Help-Aug2011.chm csc /out:resourcelib.dll /target:library /resource:FileInfo.txt /resource:Help-Aug2011.chm The code needed to read the resources from the assembly and convert them back into files is fairly simple

                private void CreateFilesFromResources() {
                Assembly a = Assembly.LoadFile(@"E:\VC\Projects\CodingTests\BinaryResource\bin\Debug\resourcelib.dll");
                foreach (String filename in a.GetManifestResourceNames()) {
                Console.WriteLine("Resource name {0}", filename);
                using (Stream rs = a.GetManifestResourceStream(filename)) {
                using (FileStream fs = File.Create(filename)) {
                Byte[] buff = new Byte[8192];
                Int32 read;
                while ((read = rs.Read(buff, 0, buff.Length)) > 0) {
                fs.Write(buff, 0, read);
                }
                }
                }
                }
                }

                Hope that helps and has given you a few ideas. Alan.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #9

                Don't you think embedding all files in a dll will bloat it? I would say a zip file is a better alternative.

                "Don't confuse experts with facts" - Eric_V

                A 1 Reply Last reply
                0
                • M Musa Biralo

                  hmmmm,a BAT file... Is there a way to store file(s) inside a BAT, which we can extract during execution? Plus I have to check conditions on a local machine which will be much difficult in from a BAT file from my understanding. If possible, i would like to use .NET applications...

                  D Offline
                  D Offline
                  Dave Kreskowiak
                  wrote on last edited by
                  #10

                  A BAT file is just a text file with DOS commands in it. There is no way to store anything else in it.

                  A guide to posting questions on CodeProject[^]
                  Dave Kreskowiak

                  1 Reply Last reply
                  0
                  • L Lost User

                    Don't you think embedding all files in a dll will bloat it? I would say a zip file is a better alternative.

                    "Don't confuse experts with facts" - Eric_V

                    A Offline
                    A Offline
                    Alan N
                    wrote on last edited by
                    #11

                    You're right, it is uncompressed and the dll size will be the sum of the individual files plus a small overhead. I have found a limit of the technique when attempting to create a dll with some large files as somewhere between 400 and 600MB when the compiler gave up.

                    Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.3053
                    for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727

                    Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.error CS0016: Could not write to output file 'e:\VC\Projects\CodingTests\BinaryResource\resourcelib.dll' -- 'Not enough storage is available to complete this operation. '

                    Alan.

                    1 Reply Last reply
                    0
                    • M Musa Biralo

                      hi there, I like to write a program which will help a general person to create a new exe file. The first exe will add some files as resources and then creates an exe. The resulting exe will basically create the files initially added. It's something like creating a setup file but here we don't have to do anything other than reproducing the files which are embedded into an exe (like self extracting file). I can't use sfx file as i have to check certain thing in the target machine before extracting.... In short, a program that will create a very stripped down version of setup file something similar to SFX file. Thanks for sharing idea or point to right directions.

                      D Offline
                      D Offline
                      David Magnotti
                      wrote on last edited by
                      #12

                      To me it sounds like your best bet is to manually create an installer. You'll have to use the resource API, and file management functions, such as CreateFile. Those two sets of libraries should help you accomplish your goal. This isn't for the purpose of executable security (File integrity) or Intellectual Property protection, is it? If so, I would recommend looking into obfuscation, using techniques such as code virtualization and runtime integrity checks.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups