pythoncmdexepyinstallersystem32

Cannot open self C:\Windows\system32\file.exe or archive C:\Windows\system32\file.pkg


I try using pyinstaller to convert *.py to *.exe and put them in system32 to try to make them a cmd command but I always get the error:

 Cannot open self C:\WINDOWS\system32\file.exe or archive 
    C:\WINDOWS\system32\file.pkg 

I tried reinstalling pyinstaller and Python and tried different commands and code but nothing works.

I made a dummy file to check if something was wrong with my code

print("test")

But that didn't work either. the command I usually use is

 pyinstaller --onefile file.py

That works great but not if I try using it as a command, I can open it as a file but not a command

I hope I can just type file and it executes but now I have to do

cd C:\Users\user\Downloads\file.exe
file.exe

Solution

  • I strongly recommend you do not put your file in System32.

    Instead add the path of wherever you keep the .exe file to path.

    See this post for how to add a directory to your path.