the Error is: PermissionError: [Errno 13] Permission denied: 'C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp\\IP.PY'

Viewed 3299

This is my code:

import shutil

original = r'C:\Users\Руслан\Desktop\HACKPROG\IP.PY'
target = r'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp'
shutil.move(original,target)

and I am getting the following Error:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\Руслан\Desktop\HACKPROG\IP.PY", line 24, in <module>
    shutil.move(original,target)
  File "C:\Users\Руслан\AppData\Local\Programs\Python\Python39\lib\shutil.py", line 820, in move
    copy_function(src, real_dst)
  File "C:\Users\Руслан\AppData\Local\Programs\Python\Python39\lib\shutil.py", line 435, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "C:\Users\Руслан\AppData\Local\Programs\Python\Python39\lib\shutil.py", line 264, in copyfile
    with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: 'C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp\\IP.PY'
2 Answers

You don't appear to have permissions to write to the Start Up folder.

You can fix this by running your Python terminal as an administrator (right click IDLE/cmd and press run as administrator).

you can run this program in 2 ways

Method 1: Add python to path, By editing environmental variables.

Method 2: Open console/cmd . Direct path to python file by

cd C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp

And then after entering directory

python ip.py --user
Related