I have to copy dll files to C:\Windows\System32 folder. I get permission denied error. Is there some way to do that other than running the script as administrator?
This did not work:
import os
import sys
import shutil
import win32com.shell.shell as shell
ASADMIN = 'asadmin'
if sys.argv[-1] != ASADMIN:
script = os.path.abspath(sys.argv[0])
params = ' '.join([script] + sys.argv[1:] + [ASADMIN])
print "params : ", params, " script : ", script
shell.ShellExecuteEx(lpVerb='runas',
lpFile=sys.executable,
lpParameters=params)
print "I am root now."
nvcudadll = "C:\\Users\\alankritag\\Desktop\\abc.dll"
winpath = os.environ['WINDIR'] + "\\System32"
shutil.copyfile(nvcudadll, winpath)