0

Мне нужно чтоб при первом запуске скрипта он добавлял сам себя в автозапуск. На windows 7 и выше.

1

1 ответ 1

1
from winreg import *
from os import path
   
PathFile = path.abspath(__file__)
# (Если будете компилировать файл в ехе тогда PathFile = path.abspath(__file__)[:-2]+'exe')

def Startup():
    StartupKey = OpenKey(HKEY_CURRENT_USER,
                    r'SOFTWARE\Microsoft\Windows\CurrentVersion\Run',
                    0, KEY_ALL_ACCESS)
    SetValueEx(StartupKey, 'name', 0, REG_SZ, PathFile)
    CloseKey(StartupKey)

Startup()

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.