I own a Windows 10 Pro computer (version 10.0.18362) and I’ve made an executable file named test.exe. Even though the executable runs successfully on other Windows machines, including other Windows 10 Pro machines, it does not run on my computer. There is no indication of any error or output when I try to run it from a cmd terminal. After attempting to run the executable, a new prompt appears below with no information in between, which is confusing. I’m curious as to why Windows is refusing to run the executable and not displaying any errors. How can I “unblock” the file and make it work?
I attempted to resolve this problem by searching on Google, and came across some suggestions. These included turning off Defender and firewall, modifying Group Policy Settings and running cmd as administrator, and adjusting the registry. Unfortunately, none of these suggestions were helpful.
Are there any other solutions that I can try?
test.exe
was created by running pyinstaller --onefile test.py
on the following (trivial) Python 3.7 program:
print("Success")
Once more, the identical executable file operates smoothly on other Windows computers. There are no firewalls, antivirus programs, defenders or shields in operation, and I am running the correct executable in the correct folder.
Additionally, I have discovered another piece of evidence: the executable works when run from a USB flash drive, but fails when executed from the C: drive.
What configurations or procedures could be the cause of this problem?
2 Answers
Introduction
Windows 10 Pro is a popular operating system that is used by many people around the world. It is known for its advanced features and capabilities. However, sometimes it can be difficult to get an executable file to run on this OS. This can be frustrating, especially if the file works on other machines. In this blog post, we will explore why Windows 10 Pro may prevent a pyinstaller generated .exe from running and how to unblock it.
What is PyInstaller?
PyInstaller is a program that converts Python programs into standalone executables, which can run on any machine without installing Python or any other dependencies. It is a popular tool among developers who want to distribute their Python programs as executables.
When you run PyInstaller on your Python program, it creates a bundle that includes a copy of the Python interpreter, your program code, and any required libraries or modules. The result is a single file that can be run on any machine without the need for Python or any other dependencies.
Why Windows 10 Pro Prevents a PyInstaller Generated .exe from Running?
Windows 10 Pro may prevent a PyInstaller generated .exe from running for several reasons. One of the most common reasons is that the file is blocked by Windows SmartScreen. Windows SmartScreen is a security feature in Windows 10 that helps protect your PC from malicious software. It checks the files that you download and run against a list of known malicious software, and if it finds a match, it blocks the file from running.
Another reason why Windows 10 Pro may prevent a PyInstaller generated .exe from running is that the file is located in a protected folder. Windows 10 Pro has several protected folders, such as Program Files, where only system administrators have permission to write. If your .exe file is located in one of these folders, you may not be able to run it.
How to Unblock a PyInstaller Generated .exe?
If Windows 10 Pro is preventing a PyInstaller generated .exe from running, there are several things you can do to unblock it. Here are some of the most common solutions:
1. Disable Windows SmartScreen
One way to unblock a PyInstaller generated .exe is to disable Windows SmartScreen. Here’s how to do it:
- Click on the Start menu and open Settings.
- Click on Update & Security, and then click on Windows Security.
- Click on App & browser control.
- Under Check apps and files, select Off.
Once you’ve disabled Windows SmartScreen, try running your .exe file again and see if it works.
2. Unblock the File
Another way to unblock a PyInstaller generated .exe is to unblock the file. Here’s how to do it:
- Right-click on the .exe file and select Properties.
- Click on the General tab.
- Under Security, click on the Unblock button.
- Click on Apply and then click on OK.
Once you’ve unblocked the file, try running it again and see if it works.
3. Move the File to a Non-Protected Folder
If your .exe file is located in a protected folder, such as Program Files, you may not be able to run it. In this case, you can try moving the file to a non-protected folder, such as your desktop or documents folder. Once you’ve moved the file, try running it again and see if it works.
4. Run the File as Administrator
If your user account doesn’t have the necessary permissions to run the .exe file, you can try running it as an administrator. Here’s how to do it:
- Right-click on the .exe file and select Run as administrator.
- If prompted, enter the administrator password.
Once you’ve run the file as an administrator, try running it again and see if it works.
5. Use Compatibility Mode
If your .exe file was created for an older version of Windows, you can try running it in compatibility mode. Here’s how to do it:
- Right-click on the .exe file and select Properties.
- Click on the Compatibility tab.
- Under Compatibility mode, select the version of Windows that the .exe file was created for.
- Click on Apply and then click on OK.
Once you’ve set the compatibility mode, try running the file again and see if it works.
Conclusion
In this blog post, we explored why Windows 10 Pro may prevent a PyInstaller generated .exe from running and how to unblock it. We discussed several solutions, including disabling Windows SmartScreen, unblocking the file, moving the file to a non-protected folder, running the file as an administrator, and using compatibility mode. By following these solutions, you should be able to get your .exe file to run on Windows 10 Pro.
You could attempt resolving the issue by adding the parameter “--win-private-assemblies
” to the executable file. This will prevent it from utilizing newer libraries that might exist on this specific system.
Any Shared Assemblies that are integrated into the application will be converted into Private Assemblies. As a result, the specific versions of these assemblies will always be utilized, and any newer versions installed on user machines at the system level will be disregarded.
Additionally, ensure that you are not actually running the executable from the root of C:\ or any other protected location.