coding enviroment: windows10 python3
Here is my code:
import os
PATH_add = os.popen(
r'''For /F "EOL=H Tokens=2,*" %G In ('%SystemRoot%\System32\reg.exe Query "HKLM\SYSTEM\CurrentControlset\Control\Session Manager\Environment" /V Path 2^>NUL') Do @%SystemRoot%\System32\setx.exe Path "%HC:\Test;" /M''')
result = PATH_add.read()
print(result)
But it show an error Error: Access to registry path is denied.
I know i need to run it as adminisator, but how can i did it.i don't mean like running the pyfile as Administaor, i just want to edit the code to fix the problem.