-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
64 lines (57 loc) · 2.39 KB
/
Copy pathmain.py
File metadata and controls
64 lines (57 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
ANTIVYRE — Free, AI-powered Antivirus
Copyright (c) 2019–2025 FreddyDeveloper (https://www.freddydeveloper.com)
License: GNU GPL v3 — Free forever. Donations welcome: https://paypal.me/freddydeveloper
"""
import sys
import os
import traceback
from pathlib import Path
# ── Hide the black CMD window on Windows ─────────────────────────────────
if sys.platform == "win32":
import ctypes
ctypes.windll.user32.ShowWindow(
ctypes.windll.kernel32.GetConsoleWindow(), 0
)
# ── Single instance enforcement ───────────────────────────────────────────
if sys.platform == "win32":
import ctypes
_mutex = ctypes.windll.kernel32.CreateMutexW(None, False, "AntivyreSingleInstance")
if ctypes.windll.kernel32.GetLastError() == 183:
# Already running — bring the existing window to front instead of showing error
HWND_BROADCAST = 0xFFFF
WM_USER = 0x0400
ANTIVYRE_SHOW = WM_USER + 1
ctypes.windll.user32.PostMessageW(HWND_BROADCAST, ANTIVYRE_SHOW, 0, 0)
sys.exit(0)
# Ensure bundled libs are importable when running as exe
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
# --startup flag is passed by the Windows registry autostart entry.
# When present, the app starts silently in the tray (no window shown).
STARTUP_MODE = "--startup" in sys.argv
def main():
try:
from ui.app import AntivyreApp
app = AntivyreApp(silent_start=STARTUP_MODE)
app.run()
except Exception as e:
# Write crash log so we can diagnose instead of silent close
log_path = Path.home() / ".antivyre" / "crash.log"
log_path.parent.mkdir(parents=True, exist_ok=True)
with open(log_path, "w") as f:
f.write(traceback.format_exc())
# Show error in a simple dialog if tkinter is available
try:
import tkinter as tk
from tkinter import messagebox
root = tk.Tk()
root.withdraw()
messagebox.showerror(
"ANTIVYRE — Startup Error",
f"ANTIVYRE failed to start.\n\nError: {e}\n\nCrash log saved to:\n{log_path}"
)
root.destroy()
except Exception:
pass
if __name__ == "__main__":
main()