Can we run a python script using ShellExecute()?

My aim is to pass arguments to a python script just like we do in cmd by running the following command
python arg1 arg2 arg3

I have added a line
ShellExecute( "python", "", "D:/Crypto/");

It opens a python shell as follows python

my is as follows (not passing the args for now as the script is not getting executed ),

	print value

I would appreciate any help.

@ninad I may be wrong, but I think you are making a mistake in using ShellExecute(). Look at this example of passing arguments to external file. Pay attention to the syntax:

A proper syntax should look like this:

ShellExecute( "filepath", "arguments", "parameters", showcmd = 1 )


try this:

ShellExecute( "python" , D:/Crypto/ arg1 arg2 arg3, D:/Crypto/ );
1 Like

There is a description how to run ".bat"

This one works:
Had looked for a solution myself.

ShellExecute("C:\\Program Files\\AmiBroker\\","","",0);

the "0" at the end prevents the cmd prompt from popping up.
Take note:

  1. when double-clicking on your file, windows needs to know the extension, i.e double-click executes it.
  2. ShellExecute won't wait for your python script to finish, that may or may not be ok
  3. try running the ShellExecute on 1 symbol + 1 bar. Otherwise you execute it many, many times


1 Like

All these solutions work ! :smiley: This is exactly what I was looking for.
Thanks @Milosz @Dionysos @aron @jamesfisher . :heart:

1 Like

I did not understand exactly what did you mean by this.
I want to call this script every time I get a buy/sell signal only. I'll see how it can be done.

if you run the ShellExecute in your .afl for say backtesting, and in your database are 100 symbols, that means you execute the ShellExecute 100 times.
(provided there are not conditional "ShellExecutes")

Of course it depends on what you are trying to achieve... yet worth mentioning.