[Python] Run the file.exe before exiting the Python program? [closed]

Discussão em 'Python' iniciado por Stack, Junho 18, 2025.

  1. Stack

    Stack Membro Participativo

    You need to run the exe file and exit the Python program, which is packaged in an executable file. I've tried different ways, but a message appears after each option.enter image description here

    As far as I understand, calling another program does not allow you to close the main application.

    I've tried these methods, but the message still appears.

    from subprocess import Popen, CREATE_NO_WINDOW, DETACHED_PROCESS,
    CREATE_NEW_PROCESS_GROUP

    '''
    Replace
    os.system(f'"{os.path.join(DOWNLOAD_TEMP_PATH, new_exe_name)}"')
    With the Followings:
    '''
    Popen(\[new_exe_name\], shell=True,
    creationflags=CREATE_NO_WINDOW | DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP)

    # \---------------------------------------------------------------------

    import os
    os.spawnlp(os.P_NOWAIT, 'cp', 'cp', '/path/large-file.db', '/path/dest')

    # \----------------------------------------------------------------

    from subprocess import Popen
    DETACHED_PROCESS = 0x00000008
    cmd = \[
    sys.executable,
    'c:\\somepath\\someprogram.exe',
    parm1,
    parm2,
    parm3\]
    p = Popen(
    cmd, shell=False, stdin=None, stdout=None, stderr=None,
    close_fds=True, creationflags=DETACHED_PROCESS,
    )

    Continue reading...

Compartilhe esta Página