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

  • SEARCH
  • Home
  • 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 6793635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:07:26+00:00 2026-05-26T18:07:26+00:00

I have an exe file that I have to call with several parameters, and

  • 0

I have an exe file that I have to call with several parameters, and for this purpose I use a bat file. After I execute bat file command prompt does not close, but wait for me to press a key. Now I have to run this exe several times, and for this I want to run a script that will do it for me.

i = 0
for path in Paths
    outout = codecs.open('runExe.bat', 'w')
    output.write(PathToExe + " -param1" + " -param2 " + param2Val[0] + " -param3 " + param3Val[0] + " -param4 " + param4Val[0] + " -param5 param5Val")
    output.close()
    subprocess.call(["regsvr32.exe", path, "-u", "-s"])
    subprocess.call(["regsvr32.exe", path, "-s"])
    subprocess.call("runExe.bat")
    i + = 1

where param3Val, param4Val, param5Val are lists with values for related command prompt parameters.
When I call this bat file, everything works perfectly for the first fun of exe, but after it executes, command promt waits for my respond. When I press any key, it closes and then exe file starts with different parameters.
So I want to eliminate with key-pressing thing. I tried to put “exit” to the end of the bat file, but it did not work. How can I close command prompt window from script, when exe finishes working?
Thanks in advance!
enter image description here
Upd1: sarmold’s way of doing thing works fine, but I think this it is exe (console application) that is waiting for my response. Smth in exe file prevents console window from closing, but I do not have access to sources. How can I close it’s window after it executes?

Upd2: I have tried to add “shell” call after subprocess.call, but this does not seem to work either, still have to respond to the console manually 🙁

shell = win32com.client.Dispatch("WScript.Shell")
shell.AppActivate("Command Prompt")
shell.SendKeys("cls(ENTER)")
  • 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-05-26T18:07:27+00:00Added an answer on May 26, 2026 at 6:07 pm

    There are two possible approaches here:

    1. Make only a single bat file that contains all your commands, including the regsvr32.exe commands, and execute that.

    2. Have the Python script do everything for you.

    For the first approach, use the "a" open mode to append to the batch file. (Perhaps delete it at script start.) Write the contents of your three commands to the batch file within the loop — so you wind up with a long batch file that includes all the commands you need.

    Then call the subprocess.call() command once, outside the loop, at the end of the script, to run the entire thing.

    For the second approach, remove all the batch-file writing and run your PathToExe using Python’s subprocess.call(). It’s almost as simple as deleting all lines that work with output, but change output.write() to subprocess.call() — and obviously, fiddle with the contents a little bit so they work for subprocess.call() directly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an exe file that I'm calling through php using the 'system' command.
I have an exe file that I'm calling through php using the 'system' command.
I have a compiled .exe file (compiled with gfortran and -g option) that crashes.
I have an exe that already creates a csv file. If I save the
I have an exe file. Lets call it X.exe It is a console application
I have a VB script that takes in several parameters that could include spaces
I have an App.config file in my project that gets copied to NameOfExe.exe.config at
I have an exe which I call from the command line. Is it possible
I have the requirement for a web script to execute an exe file and
I have created a Windows service that will run an exe file periodically to

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.