Possible Duplicate:
Request UAC elevation from within a Python script?
I have to copy a file (Say a txt) to a System folder , is there a way to do that ?
this is code i used for normal file transfer and it worked :
import os
import shutil
fileList = os.listdir('J:\hawa')
fileList = ['J:\hawa'+ '\lol.txt']
for f in fileList:
shutil.copy2(f, 'C:\Windows\System32\Drivers\etc')
but when target directory is system folder the error appears :
Traceback (most recent call last):
File "C:/Python27/copy2.py", line 8, in <module>
shutil.copy2(f, 'C:\Windows\System32\Drivers\etc')
File "C:\Python27\lib\shutil.py", line 128, in copy2
copyfile(src, dst)
File "C:\Python27\lib\shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: 'C:\\Windows\\System32\\Drivers\\etc\\lol.txt'
can i just modify the code some way or the other to make it run as admin privilege ?