Python script opens empty cmd windows

I have this code for start and stopping xampp apache and mysql.

import subprocess
import os
import time
import argparse
import sys

# XAMPP installation path
xampp_path = 'D:\projects'  # Get path from environment variable or use default

# Seconds to wait for services to start/stop
wait_time = 2

# Function to start a service using batch files
def start_service(batch_file):
    command = os.path.join(xampp_path, batch_file)
    if os.path.isfile(command):
        print(f"Starting service with {batch_file}...")
        process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, creationflags=subprocess.CREATE_NO_WINDOW)
        time.sleep(wait_time)  # Give it some time to start
        print(f"Service started successfully with {batch_file}.")
    else:
        print(f"Batch file {batch_file} does not exist.")

# Function to stop a service using batch files
def stop_service(batch_file):
    command = os.path.join(xampp_path, batch_file)
    if os.path.isfile(command):
        print(f"Stopping service with {batch_file}...")
        process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, creationflags=subprocess.CREATE_NO_WINDOW)
        time.sleep(wait_time)  # Give it some time to stop
        print(f"Attempted to stop service with {batch_file}.")
    else:
        print(f"Batch file {batch_file} does not exist.")

# Function to forcefully kill a service by its process name
def kill_service(service_name):
    try:
        subprocess.run(f"taskkill /F /IM {service_name}", check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, creationflags=subprocess.CREATE_NO_WINDOW)
        print(f"Service {service_name} killed successfully.")
    except subprocess.CalledProcessError as e:
        print(f"Error killing {service_name}: {e.stderr.decode()}")

# Parse command line arguments
parser = argparse.ArgumentParser(description="Start or stop XAMPP services.")
parser.add_argument("--start", action="store_true", help="Start XAMPP services")
parser.add_argument("--stop", action="store_true", help="Stop XAMPP services")
args = parser.parse_args()

# Start or stop XAMPP services based on command line arguments
if args.start:
    # Start Apache and MySQL
    start_service("apache_start.bat")
    time.sleep(wait_time)  # Wait a few seconds before starting MySQL to ensure Apache starts properly
    start_service("mysql_start.bat")

elif args.stop:
    # Stop Apache and MySQL
    stop_service("apache_stop.bat")
    stop_service("mysql_stop.bat")

    # Kill lingering processes after attempting to stop them gracefully
    kill_service("xampp-control.exe")  # xampp
    kill_service("httpd.exe")  # Apache
    kill_service("mysqld.exe")  # MySQL

    # Check if services are still running
    def check_service_stopped(service_name):
        tasklist_output = subprocess.check_output("tasklist", shell=True).decode()
        if service_name in tasklist_output:
            print(f"{service_name} is still running.")
        else:
            print(f"{service_name} has been stopped.")

    # Check Apache and MySQL status
    check_service_stopped("httpd.exe")  # Apache
    check_service_stopped("mysqld.exe")  # MySQL

    print("Apache and MySQL services have been stopped.")

else:
    print("Please specify --start or --stop parameter.")

sys.exit(0)

I have the file in a folder that is set in environment variables, so i’m able to run it from anywhere using:

xampp.py --start

or to stop

xampp.py --stop

Problem:
both works. but when i run xampp.py –stop it opens py.exe does its job and closes it. but along with that it opens 2 new cmd windows. and i cannot figure out why and from where it opens those.

both cmd window shows this:

The system cannot find the path specified.

D:projects>

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật