Skip to content

Commit

Permalink
An try to fix autorun in utils.py. In case, when system has problem…
Browse files Browse the repository at this point in the history
…s with registry permissions
  • Loading branch information
Denis Polishchuk committed Oct 11, 2023
1 parent cb06c17 commit 4ae90c0
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,25 @@ def openURL(link: str) -> None:
def enableAutoRun() -> None:
currentAppPath = sys.argv[0]

key = reg.OpenKey(reg.HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Run', 0, reg.KEY_SET_VALUE)
reg.SetValueEx(key, "ArciBinder", 0, reg.REG_SZ, currentAppPath)
key.Close()
try:
key = reg.OpenKey(reg.HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Run', 0, reg.KEY_SET_VALUE)
reg.SetValueEx(key, "ArciBinder", 0, reg.REG_SZ, currentAppPath)
key.Close()
except Exception as e:
print(e.message)

def disableAutoRun() -> None:
key = reg.OpenKey(reg.HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Run', 0, reg.KEY_WRITE)
reg.DeleteValue(key, "ArciBinder")
key.Close()
try:
key = reg.OpenKey(reg.HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Run', 0, reg.KEY_WRITE)
reg.DeleteValue(key, "ArciBinder")
key.Close()
except Exception as e:
print(e.mesasge)

def isAutoRun() -> bool:
key = reg.OpenKey(reg.HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Run', 0, reg.KEY_QUERY_VALUE)

try:
key = reg.OpenKey(reg.HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Run', 0, reg.KEY_QUERY_VALUE)
reg.QueryValueEx(key, "ArciBinder")
return True
except:
except Exception as e:
return False

0 comments on commit 4ae90c0

Please sign in to comment.