Hello, if anyone knows, can you suggest how to write the execution of the compiled python script into an exe file, to automatically start it with the start of the system? Interesting solutions under Win XP.

Thanks for the answer.

    2 answers 2

    Hello, this is done simply:

    #нужный для этого функционал находится в _winreg (в python3 он называется winreg) from _winreg import * #открываем нужную ветку #HKEY_CURRENT_USER - текущий пользователь #HKEY_LOCAL_MACHINE - глобально, для всех mykey = OpenKey(HKEY_CURRENT_USER, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Run') #пишем наш ключ #если не хватит прав, то будет исключение WindowsError: [Error 5] SetValueEx(mykey, 'ИМЯ_КЛЮЧА', 0, REG_SZ, 'C:\ПУТЬ_И_ИМЯ\ВАШЕГО\ФАЙЛА.exe') #можно закрыть ветку, но это не обязательно CloseKey(mykey) 

    more details docs.python.org/library/_winreg

      Register in the registry key

      HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run

      the path to your executable file.

      Description of the registry keys Run, RunOnce, RunServices, RunServicesOnce and Startup .

      • Thank you, I was just wondering how to implement adding entries to the registry program, it’s clear what I can add with my hands, but I don’t understand how software is. - Mozart
      • Look here: Autostart of the program when you turn on the computer C ++ . The easiest way to create a registry file and import it is the regedit.exe utility. REGEDIT.EXE [/ L: system | / R: user] [/ S] importfile.REG - stanislav