Lỗi chạy file exe unable to open archive file năm 2024

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Can't open EXE files

  • Article
  • 02/19/2024

In this article

This article provides a resolution for the issue that you get errors when opening exe files.

Applies to: Windows Server 2012 R2, Windows 10 - all editions Original KB number: 555067

This article was written by Yuval Sinay, Microsoft MVP.

Symptoms

When you try to open EXE files, you may get error messages like: "Access Deny", "Runtime error" and so on.

Cause

Corrupt registry settings or some third-party product [or virus] can change the default configuration for running EXE files. It may lead to failed operation when you try to run EXE files.

Resolution

  1. Click Start, and then select Run.
  2. Type "command.com", and then press Enter. [A DOS window opens.]
  3. Type the following command lines:

    cd\ cd \windows

    Press Enter after typing each one.
  4. Type copy "regedit.exe regedit.com" and then press Enter.
  5. Type "start regedit.com" and then press Enter.
  6. Navigate to and select the key:
    HKEY_CLASSES_ROOT\exefile\shell\open\command
  7. In the right pane, double-click the [Default] value.
  8. Delete the current value data, and then type: "%1" %* Tip: Type the characters: quote-percent-one-quote-space-percent-asterisk.
  9. Close Regedit utility. Note If you are using Windows XP and you enable "System Restore" , you need to disable "System Restore" in "Safe Mode" before using the instructions above.

Data collection

If you need assistance from Microsoft support, we recommend you collect the information by following the steps mentioned in Gather information by using TSS for deployment-related issues.

Community Solutions Content Disclaimer

Microsoft corporation and/or its respective suppliers make no representations about the suitability, reliability, or accuracy of the information and related graphics contained herein. All such information and related graphics are provided "as is" without warranty of any kind. Microsoft and/or its respective suppliers hereby disclaim all warranties and conditions with regard to this information and related graphics, including all implied warranties and conditions of merchantability, fitness for a particular purpose, workmanlike effort, title and non-infringement. You specifically agree that in no event shall Microsoft and/or its suppliers be liable for any direct, indirect, punitive, incidental, special, consequential damages or any damages whatsoever including, without limitation, damages for loss of use, data or profits, arising out of or in any way connected with the use of or inability to use the information and related graphics contained herein, whether based on contract, tort, negligence, strict liability or otherwise, even if Microsoft or any of its suppliers has been advised of the possibility of damages.

We use PyInstaller to package our python scripts to an EXE file with the -F option. Most of the time the executables run without problem. But sometimes, we got the problem says "Cannot open archive file". We encountered this problem not only on one executables.

We tried to use the latest version of PyInstaller [6.1.0] to repackage one script and test, but we still get the similar error message "Failed to extract pyi_rth_pkgres: failed to open archive file!" occationally.

We tried to figure out the root cause and find the solution by searching the Internet, but we still cannot find any clue after weeks.

Does anyone know about this? What causes the problem and how to solve it?

The text was updated successfully, but these errors were encountered:

If you encounter Failed to extract pyi_rth_pkgres: failed to open archive file!, then it means that we failed to open the executable for reading . To get to this point, we had to be able to open it for reading at least once before [where the archive is initially parsed], so this suggests that on the problematic system, there is intermittent issues with access to the file. Either because of anti-virus program, network drive, some other OS issue, and so on.

Thank rokm for the quick reply.

I had checked the PyInstaller source files before, we found there are two places that will print such messages, one is the place you mentioned, the other is . According to the , I thought the problem was at the later one. Then is it also possible to fail there?

There do is an anti-virus software running in these environments. But before attributing to the anti-virus, I want to exclude all other possible causes first, since it's hard to get the evidence of the anti-virus software.

Causing by network drives can be excluded, because the executables reside in hard disks, e. g. drive C or drive D.

At first, we thought it's related to the concurrent running of the executable. In these environments, the same executable may be launched by many different processes simultaneously. But I checked the source code, the temporary folder name consists of PID, and even if the name conflicts, the process will exits without such message. It seems the concurrent running doesn't matter.

Thank rokm for the quick reply. I had checked the PyInstaller source files before, we found there are two places that will print such messages, one is the place you mentioned, the other is . According to the , I thought the problem was at the later one. Then is it also possible to fail there?

It is also possible to fail here, yes [for the same reasons]. But pyi_rth_pkgres is extracted into memory, not on the filesystem, so that particular error message was encountered in the codepath that I linked. But if the error is sporadic, you can probably see it for both cases.

There do is an anti-virus software running in these environments. But before attributing to the anti-virus, I want to exclude all other possible causes first, since it's hard to get the evidence of the anti-virus software.

Causing by network drives can be excluded, because the executables reside in hard disks, e. g. drive C or drive D.

At first, we thought it's related to the concurrent running of the executable. In these environments, the same executable may be launched by many different processes simultaneously. But I checked the source code, the temporary folder name consists of PID, and even if the name conflicts, the process will exits without such message. It seems the concurrent running doesn't matter.

This is about opening executable file for reading, so concurrent access from multiple processes should not matter [unless CRT has some limitation on that which I am not aware of]. I would find it more likely that the hypothetical anti-virus program is trying to gate access, and causes issues when there are multiple simultaneous requests.

Thank rokm for the quick reply.
I had checked the PyInstaller source files before, we found there are two places that will print such messages, one is the place you mentioned, the other is . According to the , I thought the problem was at the later one. Then is it also possible to fail there?
It is also possible to fail here, yes [for the same reasons]. But pyi_rth_pkgres is extracted into memory, not on the filesystem, so that particular error message was encountered in the codepath that I linked. But if the error is sporadic, you can probably see it for both cases.

It might also be worth noting that run-time hook [such as pyi_rth_pkgres] and entry-point script extraction happens after data and binaries are extracted to the temporary directory [so in this particular cases, the open attempts in the code path that you linked must have all suceeded]. It also happens in the child process [the one that runs python interpreter and those scripts], as opposed to the parent process [which does the data and binaries extraction].

Thanks rokm, I will try to configure the anti-virus program to exclude the folder where the executable locates and observe whether the problem happen again.

Is excluding this folder enough, do I need to exclude other folders, for example the folder where the temporary folder locates? The temporary folder is created in the Windows temp folder, exclude the Windows temp folder is not safe.

I think excluding the executable [or its location] should do the trick, if this is what is causing the problem.

I don't think there is any need to exclude the temporary directory, though - unless you receive an error message that indicates that we failed to open the target file in the temporary directory [as opposed to failing to [re]open the executable file and its embedded archive].

Chủ Đề