[Python] Not able to convert python file containing while loop into exe which runs silently in...

Discussão em 'Python' iniciado por Stack, Novembro 28, 2024.

  1. Stack

    Stack Membro Participativo

    I have made a python script which basically has a while loop which waits for a particular exe to start, and as soon as it opens it shuts down the system. But the thing is that the exe file when run, keeps on opening and shutting the console window.

    I tried using --noconsole and --windowed as well, but still for a brief moment the console window pops up and disappears, this keeps on repeating, so it's very obvious that there's a background file running.

    The alternative might be to not use an infinite loop but I am not able to figure that out.

    Here's the code:


    def process_exists(process_name):
    call = 'TASKLIST', '/FI', f'imagename eq {process_name}'
    output = subprocess.check_output(call).decode()
    last_line = output.strip().split('\r\n')[-1]
    return last_line.lower().startswith(process_name.lower())

    def time ():
    while True:
    if process_exists("RobloxPlayerBeta.exe") or process_exists("RobloxPlayerLauncher.exe"):
    os.system("shutdown /s")
    if process_exists("Windows10Universal.exe"):
    # os.system("shutdown /s")
    print("Okay")


    time()

    Continue reading...

Compartilhe esta Página