Download MetaTrader 5

Syntax for calling AutoIt compiled Script (.exe) using ShellExecuteW in MT4 EA

To add comments, please log in or register
Olga Smirnova
114
Olga Smirnova  

Using the below syntax to send values from EA to AutoIt compiled script as below.

    double value1 =234
    double value2 = 678
    double  value3 = 888
    ShellExecuteW(0,0,"D:\tstScript.exe","value1 value2 value3","",1);

    Getting below error

    Access violation read to 0x000000EA in 'C:\Users\MetaQuotes\Terminal\C01E4824CB1310748719A488ACBDC5BA\MQL4\Libraries\shell32.dll'.

The below command works when invoked from Command prompt
    tstScript.exe 23 45 33

whroeder1
15350
whroeder1  
  1. There is no such executeable at "D:<TAB>stScript.exe" Character Constants - MQL4 Documentation
  2. The second argument must be a string.
  3. The argument you are passing to the script is "value1 value2 value3" not "234 678 888"
  4. Unable to run batch file - MQL4 forum



Olga Smirnova
114
Olga Smirnova  

Thanks for the reply. Tried the below commands suggested in the post by moving the .exe to folder C:\\Users\\user1\\AppData\\Roaming\\MetaQuotes\\Terminal\\C01E4824CB1310748719A488ACBDC5BA\\MQL4\\Files.

Script 2 & 3 works without the arguments.  But I am required to pass the arguments to this script.

Script 1 & 4 with cmd.exe , it just opens up an cmd window ( with path C:\Program Files (x86)\MAK4 Trader ) and does nothing . Am I missing anything here??

    1.  ShellExecuteW(0,"Open","cmd.exe","/C C:\\Users\\user1\\AppData\\Roaming\\MetaQuotes\\Terminal\\C01E4824CB1310748719A488ACBDC5BA\\MQL4\\Files\\tstScript.exe 45 67 88",NULL,5);
    2.  ShellExecuteW(0,"Open","C:\\Users\\user1\\AppData\\Roaming\\MetaQuotes\\Terminal\\C01E4824CB1310748719A488ACBDC5BA\\MQL4\\Files\\tstScript.exe 45 67 88",NULL,NULL,5);
    3.  ShellExecuteW(0,"Open","tstScript.exe 5 6 7 ",NULL,terminalDataPath,5);
    4. ShellExecuteW(0,"Open","cmd.exe","/C tstScript.exe 4 5 6",terminalDataPath,5);


Is this syntax a valid one, to pass dynamic arguments ?

 Here .exe is AutoIt compiled script .

 string value1 =234
    string value2 = 678 
    string value3 = 888

  ShellExecuteW(0,"Open","cmd.exe","/C tstScript.exe"+value1+" "+value2 +" "+value3,terminalDataPath,5);
 
To add comments, please log in or register