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.
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 .
Source: https://ru.stackoverflow.com/questions/80958/
All Articles