# Why is it not recommended to run a .exe file directly from a .zip file?

I thought that I could ZIP up a .exe file for portable use. But Windows says it won't work because it might depend on other files in the compressed folder.

What does this mean? Why can't I just run the program from the zip file? The application could use a relative path instead of a direct path to access other files.

• If you see only a single file in the ZIP or the file is specifically designed to be used mobile and if you use it and it works there is no problem with running it this way (besides the additional wait time for unzip and potentially Malware detection who does not like to execute binaries from temp directory). Those mentioned "if"s are the reason why it is not generally recommended. Very commonly for example online help will not work if the prog needs a chm/hlp file. – eckes Mar 9 at 20:10
• The reason Windows tells you this because a common way to distribute software used to be to zip up the installer and all the related files, and tell the end user to run setup.exe/install.exe. The user would double-click that file in the zip archive and (unless they used WinZip, which has handled installers for years) only that file would get extracted to a subdirectory of %temp% and then get executed, which would result in an error as setup.exe couldn't find any of the files it needed to work. So, instead of handling it like WinZip does, they show a vaguely-worded message to confuse people. – Aaron F Mar 9 at 22:08
• Just a BTW, having a ISO file (system) is less compressed but much more transparent for Windows and Linux. You can mount it as a disk and all files are readily available without the need of temporary extracts. For an installer with additional external files I would prefer that, as it does not require double extract space and is still a single file to store. – eckes Mar 10 at 7:28
• What is the actual message from Windows? Can you add the literal message or a screenshot to your question by editing it? (but without "Update" or "Edit") – Peter Mortensen Mar 10 at 13:05
• @PeterMortensen: I agree with the previous comment. Your edit to the title completely changes the question and, given the sole and accepted answer, is clearly contrary to the author's actual intent. Your edit should be rolled back. – Peter Duniho Mar 10 at 16:39

Executable files (.exe) can rely on other files for proper execution. For example, they might need a dynamically linked library (.dll) to run external code, a text file (.ini, .txt, etc) for configuration, or a database file for - well, data.

When running an executable from within a an archive, like a .zip file, those files might not get extracted and the program will not work as intended. Alternatively, the program might run and create those files in a different location. If you then moved that archive to another computer, those files will not be there.

If you are 100% positive that running the program from within the archive will not cause any issues, then you can safely ignore the message.

• A little improvement in wording: Before execution, the .exe is extracted from zip archive into temporary directory and then it is executed. The files it (potentially) depends on are not extracted and this may cause the .exe to fail. If the .exe does not depend on other files from the archive, it will run just fine. – Fiisch Mar 9 at 12:51
• Something else I've noticed is that some programs may have problems writting on the path where they are extracted to. – Ismael Miguel Mar 9 at 12:54
• "If you then moved that archive to another computer, those files will not be there" - this will of course depend on the application used to open the archive, but the files might be gone once you close the executable or archive, or they may not shared between multiple attempts to open the archive or executable or simply be hard to find. – NotThatGuy Mar 9 at 13:01
• Also executing executables directly from the temp folder is unreasonably dangerous. Too many ways of dropping dlls into the temp folder have been found over the years. – Joshua Mar 10 at 22:42
• @Phoenix At some point in time, a malicious DLL gets dropped into the temp folder. Later, you run an .exe from the templ folder (e.g. "directly" from a .zip). That .exe then picks up the malicious DLL instead of the one it was supposed to (the one that stayed in the archive, for example). – Angew is no longer proud of SO Mar 11 at 10:15

Although modern Windows makes ZIP files look like folders, this is only skin deep. A program can't do something like open('c:\foo.zip\bar.txt','rb').

So when you double click on a file in a ZIP file, Windows extracts the file to a temporary directory, then opens the temporary file.

This is problematic in a couple of ways. Firstly, if the temporary file is modified then modifications won't find their way back into the ZIP file. IIRC, Windows mitigates this by marking the temporary file as read-only. Secondly, if the file depends on other files being available in the correct relative locations, they won't be found.

Many executables depend on support files, so MS added the warning with an option to either extract just the executable file, or to extract everything in the ZIP file.

Neither is really suitable for many "portable applications" though, because of the issue that there is no way for modifications to the programs data files to find their way back into the ZIP file.

There are many reasons why running an .exe from a zip could cause problems.

Firstly as mentioned, when you "run" the file, it is actually extracted to a temporary location, then executed.

Immediate issues mean, any files that might have also be Zipped with the EXE will likely not have been extracted, and therefore not accessible. This may include libraries required to run the .exe, config files, even things as simple as help files.

Also even if you did zip everything "you thought" the file needed (into the zip file), and these are some how extracted, modern installations frequently include things like:

Data added to the windows registry library/driver files stored in other locations, as they may be shared with other programs registration of library/driver files

That's just the basics

You then have the other potential added issues, of access/file rights, these may be missing and the program may incorrectly execute as a result.

Then even if you get the program running, most modern apps require the saving of some sort of config data, for future usage. As the app is in a temp location, it will likely be deleted (along with any files it creates), and virtually impossible to find again anyway (yes I know it's not actually impossible, but it's not very manageable). And it's worth noting anything created by the app will likely not find it's way back to the zip.

So unless you have a self-contained app that required no config saving, and is specifically designed to be run as a standalone app, best not to try and run it from a Zip.

If you are trying to make something portable, it's usually a better option to use apps designed to be run from a memory stick or virtual drive.

Hope this helps.