thekid77777
thekid77777

Reputation: 391

How to get past a window prompt while calling a subprocess

I have a jar file that I want to run in the command line and collect it's stdout with a python script.

I make the call as a subprocess like:

def get_output():
  process = subprocess.run(['java', '-jar', 'myjar.jar', 'myfileargument'])

But a warning prompt comes up that I am unable to disable, which pauses execution until a user clicks 'OK' or presses enter. Is there a way to essentially 'click ok' in the prompt window that comes up via code and let the python script continue?

Upvotes: 0

Views: 45

Answers (1)

Lenormju
Lenormju

Reputation: 4378

If there is no way for you, only using environment variables and parameters to the subprocess, to disable that warning, there is no easy way to do it.

Either you will have to go the road of UI automation, as mentionned by @furas in the comments. It may be relatively easy to do so given the multiple tools/frameworks there is to do that.

Or you may "patch" the jar to not require this warning. If you can replace the annoying .class file by another which will not require to accept the warning, it may be somewhat efficient. Or else you could install a custom ClassLoader in the java program, but it may prove to be difficult.

Upvotes: 1

Related Questions