Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8444365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:23:11+00:00 2026-06-10T09:23:11+00:00

How can I make a batch file execute multiple (Python) scripts sequentially, each in

  • 0

How can I make a batch file execute multiple (Python) scripts sequentially, each in their own window, and keep all those windows open upon completion? Right now, my batch is something like:

python script1
start python script2
pause/cmd

But only the parent window stays open.

thanks.

Environment:
Windows XP/Vista

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T09:23:12+00:00Added an answer on June 10, 2026 at 9:23 am

    [to] execute multiple (Python) scripts sequentially, each in their own window, and keep all those windows open upon completion

    #!/usr/bin/env python
    """Continuation-passing style (CPS) script.
    
    Usage:
    
       $ python cps.py script1.py arg1 arg2 -- script2.py a b c -- script3.py ...
    """
    import platform
    import sys
    from subprocess import call
    
    if len(sys.argv) < 2:
        sys.exit() # nothing to do
    
    # define a command that starts new terminal
    if platform.system() == "Windows":
        new_window_command = "cmd.exe /c start cmd.exe /c".split()
    else:  #XXX this can be made more portable
        new_window_command = "x-terminal-emulator -e".split()
    
    # find where script args end
    end = sys.argv.index('--') if '--' in sys.argv else len(sys.argv)
    
    # call script; wait while it ends; ignore errors
    call([sys.executable] + sys.argv[1:end])
    
    # start new window; call itself; pass the rest; ignore errors
    rest = sys.argv[end+1:]
    if rest:
        call(new_window_command + [sys.executable, sys.argv[0]] + rest)
    
    print("Press Enter to exit") #NOTE: to avoid raw_input/input py3k shenanigans
    sys.stdin.readline()
    

    It supports as many scripts with their arguments as you can supply on the command line.

    If you don’t use arguments for scripts; you could simplify the usage:

    $ python cps.py script1.py script2.py script3.py
    

    Note: no -- between scripts. You need to modify the code in this case:

    • set end = 2
    • and rest = sys.argv[end:] (Note: no +1)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can make batch or vbs file on windows and run. this can automate
How can I make a batch file wait until another batch file has finished?
Is it possible to make a batch file which can make a persistent change
I need to make a batch file that can copy files from one path
I want to make a batch file that will search for all files in
I can make my program write a .dat file with an array of Node
How can make a link within a facebox window that redirects it to another
I wanted to make mysql dump files using a batch file and an app
I'm trying to make a batch file that makes a backup of the USB
I am trying to write a batch file to iteratively execute a fortran compiled

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.