1

I'm trying to build an auto-installer for a modpack I've made for a Minecraft server in Python. It installs Forge by copying the files from the forgefiles folder (unzipped from files.zip) to %appdata%\.minecraft\versions, and the mods from the mods folder (again, unzipped from files.zip) to %appdata%\.minecraft\mods. However, when I run my code, it comes up with this:

AutoInstaller Alpha 1
Created by ByeMC
This installer will save to "%appdata%\.minecraft". Press enter to continue.
Copying mods
Traceback (most recent call last):
  File "Z:\Mods\Minecraft\Modpacks\MiinCraft SMP\autoinstaller_v1.py", line 17, in <module>
    shutil.copy(filepath, "%appdata%\.minecraft")
  File "C:\Users\qwerty\AppData\Local\Programs\Python\Python39\lib\shutil.py", line 418, in copy
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "C:\Users\qwerty\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: 'Z:\\Mods\\Minecraft\\Modpacks\\MiinCraft SMP\\mods'

Here is my code:

print('AutoInstaller Alpha 1')
print('Created by ByeMC')

input('This installer will save to "%appdata%\.minecraft". Press enter to continue. ')

import shutil
import os
from zipfile import ZipFile

with ZipFile('files.zip', 'r') as zip:
    zip.extractall()

print('Copying mods')
dirname = os.path.dirname(__file__)
filepath = os.path.join(dirname, "mods")
shutil.copy(filepath, "%appdata%\.minecraft")
print('Copied mods to "%appdata%\.minecraft\mods". Copying Forge Files.')
filepath = os.path.join(dirname, "\forgefiles")
shutil.copy(filepath, "%appdata%\.minecraft\versions")
print('Copied Forge Files.')

I would appreciate any help you can give.

[Edit: I know the code above only works in Windows, all my friends palying on the server use Windows]

ByeMC
  • 15
  • 3
  • Have you tried running the program from an admin command line? I know this isn't really a solution but it might be a good enough work around- further [this](https://stackoverflow.com/a/62244490/9590327) might be of some value – Elephant Mar 28 '21 at 08:39
  • Sorry, the command line in admin doesn't work – ByeMC Mar 28 '21 at 08:43
  • [How AccessCheck Works](https://learn.microsoft.com/en-us/windows/win32/secauthz/how-dacls-control-access-to-an-object). – IInspectable Mar 28 '21 at 09:09

0 Answers0