The setuptools installer for Windows 7 x86 is named an exe file, but can be opened as a zip file. When I peek into it, there are two top level folders: PURELIB and SCRIPTS. What are these, and how is it that when I double click on this exe, Windows runs it for me, although it's a zip file? That is, how does Windows know what to run inside this zip/exe? Thanks.
It's a self-extracting archive.
A self-extracting archive is a computer application which contains a
file archive, as well as programming to extract this information. Such
file archives do not require a second executable file or program to
extract from the archive, as archive files usually require. The files
in an archive can thus be extracted by anyone, whether they possess
the appropriate decompression program or not, as long as the program
can run on their computer platform.
It is an executable, it's just that your extraction software knows to look for self-extracting archives, and treats it as a normal archive.
What are these, and how is it that when I double click on this exe,
Windows runs it for me, although it's a zip file?
From http://zziplib.sourceforge.net/sfx-make.html
The basic scheme goes like this: the final file will have an EXE
starting at offset null, followed by the data entries of a ZIP
archive. The last part of the ZIP archive is the ZIP central-directory
which ends at the end of the file.
The magic is possible because exe format allows any data to be appended to the executable and zip format allows any data to be prepended to the archive.
Related
I've made a nsis installer for my application and want to change one of the files inside the installer .exe. Is there a way to open the installer and change one of the files inside, similar to ZipFile?
The reason for doing this is I want to add a unique token so I can later identify which user has downloaded the app. Generating a new installer from scratch with the token inside would be too slow.
No, you cannot change files inside the installer.
What you can do however is to append some text to the end of the exe on the server and then read it in the installer.
If you have a lot of data, you can append it in a .cab file and use the CabX plug-in (CabX::FromSelf).
I'm unfamiliar with the terminology used for linking files into executables as they are compiled.
I want to write a Python script that extracts .icos from Windows executables that are viewable when you make file associations inside Folder Options. These are simply linked into the executable file upon compilation.
Then the script would sort the .ico files into individual folders based on their origin (it's supposed to extract all from subfolders/recursively) and even tell the difference between recently installed files and files that were left there previously.
Is there a library available that does such? Would I have to use a Python "Windows unlinker" or could I have it scan through RC resources too? Would there at least be a .DLL I can access with Python that does so?
Is it possible to repack/rebuild a PyInstaller exe file after extracting the files from it using PyInstaller Extractor? I also decomplied most of the files with Easy Python Decomplier. I modified one .py file and I want the new exe file to contain this modified file. How can I repack the application?
You may leave all not modified files as *.pyc.
Once you have full modules structure ready, just find the original entrypoint and pack the bundle again, it should work.
I want to make an executable file which will extract multiple files into a specific location.
I've read about the 'extractall()' function, and using unzip, but how do I contain the multiple files inside the executable python file, so each time the user double click the exe file, it will extract these files into the hard coded location?
Be aware that your archive will be (in most part) platform-specific -- it may not work on Windows if you make it on a Unix-like machine and vice versa, etc.
I would recommend that you check this pymakeself which is a pypi https://pypi.python.org/pypi/pymakeself
In fact, you may find the following codes immediately relevant.
Self Extracting Archiver (Python recipe): http://code.activestate.com/recipes/577485-self-extracting-archiver/
Build a compressed self-extracting executable script on UNIX (Python recipe): http://code.activestate.com/recipes/497000-build-a-compressed-self-extracting-executable-scri/
Everything seems to be only available in self-extracting .exe. My company blocks executable files from being downloaded.
Pretty close. Download the source - a .tar.gz archive, so you need something beyond window's built-in zip handling to unpack it - and run python setup.py install.
You could try to "easy-install" the package
The self-extracting exe is only necessary if the package contains C-code that needs to be compiled, and you don't have a compiler. Otherwise you can use the source package, which often is a tgz.
If it's a "self-extracting" zip file you can just change the .exe extension to .zip and then unzip it with any standard zip file handling utility...assuming you can at least download .exe files. If you can't, you might be able to rename them during the download process (i.e. via a "Save As" dialog).