0

I was trying to copy file from my desktop to System32 dir. it give me the following error.

PermissionError: [Errno 13] Permission denied:'C:/Windows/System32/abc.exe'

here is my code

    src = pth + "\\" +s_name
    dist = "C:/Windows/System32/"
    shutil.copy(src , dist)
3
  • it gives me the following error. Alright, have you done any debugging? That error message seems rather clear to me, no? Commented Apr 29, 2020 at 7:54
  • why would you want to mess with the System32 directory in the first place? Also, try to avoid things like src = pth + "\\" +s_name - have a look at how to properly handle paths in Python, e.g. with the pathlib module. Commented Apr 29, 2020 at 7:59
  • pth = "C:\Users\Turtle\Desktop\new project" s_name = "abc.exe" Commented Apr 29, 2020 at 8:07

1 Answer 1

2

The issue is not with Python or shutil. Permission denied means that the user that runs the Python script does not have a permission to copy the file to C:/Windows/System32.

I think what you could do now is to look for a way to run the script as Windows administrator.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.