Why I cant add my executable to windows register?

  python, python-3.x, registry

I wrote this code to convert python script to exe then add the exe to register so the program can run after every bootup

    def add_to_startup(): # to add the program to startup
        shutil.copyfile(sys.executable,location)
        subprocess.call(r'reg add HKCUSoftwareMicrosoftWindowsCurrentVersionRun /v update /t REG_SZ /d "' + location + '"',shell =True)# to add your EXE to register
        print("completed")
add_to_startup()

when I run it as python the function works but when I convert it to exe it won’t

Source: Python-3x Questions

LEAVE A COMMENT