I am attempted to have my code install a font file (.ttf) onto the computer so that it can be used by the program. I am attempting to do this by moving the .ttf file into the C:/Windows/Fonts folder. In order to do this, the program needs administrator permissions, and so I have used PyUAC to grant this permission. However, I still get [Errno 13] Permission denied: 'C:\\Windows\\Fonts'. Is there a way to fix this, or is what I am attempting impossible?
Code:
import pyuac
if pyuac.isUserAdmin() == False:
try:
pyuac.runAsAdmin()
INITIALIZEFONT()
except: #User denied administrator permission
pass
else: #pyuac.isUserAdmin() == True:
INITIALIZEFONT()
from shutil import copyfile
def INITIALIZEFONT():
try:
fontPath = 'C:\\myPath\\Copperplate.ttf'
copyfile(fontPath, 'C:\\Windows\\Fonts')
except Exception as err:
print(err)
breakpoint()
input()
My breakpoint confirms that the program does indeed have administrator permission.
[Errno 13] Permission denied: 'C:\\Windows\\Fonts'
> c:/MYPATHHERE.py(19)INITIALIZEFONT()
-> input()
(Pdb) pyuac.isUserAdmin()
True
(Pdb)
This question should not be considered a duplicate because the OP is asking how to move the file, not about permissions.
This is because the
C:\Windows\Fontsfolder isn't a real folder.You can't, and shouldn't, try to copy font files there. You should instead use AddFontResource
Bonus Reading from Michael Kaplan (rip):