Create an exe which will produce other exe file
-
Creating a Self Extracting Executable[^] Self-extracting ZIP[^] Personally I would go for the self extracting zip
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[^]
-
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.
Maybe a BAT file? :-D
-
Maybe a BAT file? :-D
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...
-
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...
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
-
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.
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
-
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.
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 simpleprivate 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.
-
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 simpleprivate 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.
-
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...
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 -
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
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.50727Copyright (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.
-
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.
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.