Windows – Creating a single file executable from a directory in Windows

packageswindows

There's an answer there, but it's two years old, and provides no information on how to do it.

Situation: I have a folder with an executable file, some required dlls and some images.
I want to package all this into a single executable file. If executed, it will run the executable file.

I've found this superuser post. However, it doesn't seem to offer a solution.

If you're familiar with Python, there's an application called PyInstaller. It creates single-file executables from python sourcecode.

I'm not sure about the exact inner-workings of it, but it generally does something like this:

  • Wrap the directory with executable into a new executable, ex app.exe
  • the new executable executes a program, which unpacks the hidden directory into a temporary folder, a folder called _MEIxxxxx, x's being numbers. For example: C:\Users\Me\AppData\Local\Temp\_MEI188722
  • execute the program from that folder.

From what I've read, they use hackery dark-magic to make this work. I'm wondering if there is a program that does this kind of dark-magic for non-python files.

Best Answer

nsis http://en.wikipedia.org/wiki/Nullsoft_Scriptable_Install_System would be the best option I have seen. I have made several wrappers for work apps that we don't want users poking around the files used to repair their pc etc. I just built a virus scanner front end this week that auto downloads msert/mcafee stinger/mcafee rootkit using the corp proxy and then runs all 3 apps for the tech's.

you could do what your asking with a standard template/example, in the main section set the out dir [ $OUTDIR %temp%_MEI188722 ] and add a [ file yourapp.exe ] line for each file in the original directory that the program needs. next use a execwait line to run the application in question. a command for sleep 20ms and then delete %temp%_MEI188722 so that the files get removed after they are not being used.

Setting the installer to silent mode would keep any standard installer dialog boxes from showing up and your app would just load after a moment. or you could create custom dialog pages if you needed the user to select any options first or wanted the app to return a message if it had some kind of error. The tutorials and community are quite active and help full so once you get used to how nsis does things it should be straight forward. http://hmne.sourceforge.net/ this is a handy program to allow you to more easily edit the script file to allow you to make the exe.

Related Question