Hide Windows scheduler bot execution

This commit is contained in:
whdwo
2026-07-02 16:06:14 +09:00
parent c43163629d
commit 80457fe6c4
5 changed files with 40 additions and 4 deletions
+9 -1
View File
@@ -11,6 +11,14 @@ PID_FILE = PROJECT / "logs" / "bot.pid"
LOG_FILE = PROJECT / "logs" / "bot_stderr.log"
def _bot_python() -> str:
if os.name == "nt":
pythonw = Path(sys.executable).with_name("pythonw.exe")
if pythonw.exists():
return str(pythonw)
return sys.executable
def _taskkill(pid: int) -> None:
subprocess.run(["taskkill", "/PID", str(pid), "/F"], capture_output=True, text=True)
@@ -69,7 +77,7 @@ def _start_bot() -> int:
with open(LOG_FILE, "a", encoding="utf-8") as log:
proc = subprocess.Popen(
[sys.executable, "-u", "app/main.py"],
[_bot_python(), "-u", "app/main.py"],
cwd=PROJECT,
creationflags=creationflags,
stdout=log,