Reputation: 35730
I wrote a program that will copy a file called a.exe to C:/Windows/
, then I pack it to exe with PyInstaller, and rename the exe file to a.exe. When I run the exe file, it output IOError [Errno 13] Permisson denied: 'C:/Windows/a.exe'
, but the file a.exe
was copied to the directory C:/Windows
. Then I ran it as the Administrator, it happened again...
At first, I copy the file with shututil.copy
, then I wrote a function myself(open a.exe, create a.exe under C:/Windows, read a.exe 's content and write to C:/Windows/a.exe, close all), but it doesn't help...Any ideas?
Upvotes: 4
Views: 2723
Reputation: 172259
Can you copy files that are open in Windows? I have a vague memory that you can't, and the file will be open while you execute it.
Is it really being copied? It doesn't exist there before copying? Did it copy the whole file?
Upvotes: 0
Reputation: 748
Check if a.exe has read-only attribute. shutil.copy raises "Permission denied" error when it is called to overwrite existing file with read-only attribute set
Upvotes: 4
Reputation: 29923
Apparently you're trying to execute a file that moves itself to a different place ... I guess that cannot work.
Upvotes: 0