import subprocess
import sys

TASK_NAME = "AutoCommitBot"


def create_startup_task():

    python_path = sys.executable

    command = f'"{python_path}" -m autocommitbot.auto_commit'

    result = subprocess.run(
        [
            "schtasks",
            "/create",
            "/sc", "onlogon",
            "/tn", TASK_NAME,
            "/tr", command,
            "/f"
        ],
        capture_output=True,
        text=True
    )

    if result.returncode == 0:
        print("Startup task created successfully.")
    else:
        print("Failed to create startup task.")
        print(result.stderr)