我必须将dll文件复制到C:\ Windows \ System32文件夹。我得到许可拒绝错误。除了以管理员身份运行脚本之外,还有其他方法吗?
这不起作用:
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)